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
- insert, and
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 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.