Oracle Object Type and Object Table

614 views Asked by At

I have created an object type and a table. I would like to know how select, insert, update and delete operation on it.

create table employee_info (
  empid number,
  emp_name varchar2(50),
  department varchar2(20),
  designation varchar2(50),
  salary number
);

create type employee_info_obj is object (
  empid number,
  department varchar2(50),
  designation varchar2(50),
  salary number
);

create type employee_info_obj_t is
table of employee_info_obj ;
1

There are 1 answers

6
William Robertson On

You have only created an object type and an unrelated database table. If you want a database table based on the type, you need to create one:

create table employee_info of employee_info_obj;

While it can be nice in certain programming scenarios to have a type synced to a table, there are some downsides such as it being harder to add columns later, and third party tool support since the object table will not be listed in user_tables but only in user_object_tables and user_all_tables, so I would question the usefulness of this approach.

dbFiddle