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:
CREATE TYPE employee_type AS OBJECT
(
employee_id NUMBER (6),
last_name VARCHAR2 (25),
job_id VARCHAR2 (10)
);
/
CREATE VIEW it_prog_view OF employee_type
WITH OBJECT IDENTIFIER (employee_id) AS
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.

Embedded_OID

1)
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

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

3)
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.

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

Oracle Enterprise Manager 13c