Data Structures   «Prev 

Object view is a Virtual Object Table

Just as a view is a virtual table, an object view is a virtual object table. Each row in the view is an object, which is an instance of an object type. An object type is a userdefined data type and you can
  1. retrieve,
  2. update,
  3. insert, and
  4. delete
relational data as if it were stored as an object type. You can also define views with columns that are object data types, such as objects, REFs, and collections (nested tables and VARRAYs). Like relational views, object views can present only the data that database administrators want users to see. For example, an object view could present data about IT programmers but omit sensitive data about salaries. The following example creates an employee_type object and then the view it_prog_view based on this object:
employee_id NUMBER (6),
last_name VARCHAR2 (25),
job_id VARCHAR2 (10)
CREATE VIEW it_prog_view OF employee_type
SELECT e.employee_id, e.last_name, e.job_id
FROM employees e
WHERE job_id = 'IT_PROG';

Object Views

Object views are useful in prototyping or transitioning to object-oriented applications because the data in the view can be taken from relational tables and accessed as if the table were defined as an object table. You can run object-oriented applications without converting existing tables to a different physical structure.


Create type dept_type as object(
  dept_name char(40),
  dept_supervisor char(40)
First we create an object type called dept_type that holds the department column definitions dept_name and dept_supervisor

create table dept of dept_type;
Next we define the department table using this type.

create type emp_type as object
  emp_name char(40),
  department ref(dept_type)

Now we create the employee_type. Note that the department column is strongly typed. That is, the department column may only contain OID's belonging to department objects. Oracle does not allow you to insert an OID for any other table into this column.

create table employee of emp_type;
Finally we define the employee table

Oracle Enterprise Manager 13c