Creating and Using Complex Views

Complex views contain subqueries that:

  • Retrieve rows from multiple base tables.
  • Group rows using a GROUP BY or DISTINCT clause.
  • Contain a function call.

CREATE TABLE departments
(department_id             number(10)        not null,
 department_name           varchar2(50)      not null
);

CREATE TABLE employees
( employee_id          number(10)      not null,
  last_name            varchar2(50)      not null,
  job_id               varchar2(30),
  department_id        number(10),
  salary               number(6),
  manager_id           number(6)
);


SQL> CREATE VIEW emp_and_dept_view AS
  2  SELECT p.employee_id,
  3         p.last_name,
  4         d.department_name
  5  FROM employees p FULL OUTER JOIN departments d USING (department_id)
  6  ORDER BY p.employee_id;

View created.

SQL>

The following example queries the view just created:


SELECT * FROM emp_and_dept_view;
Home »
Oracle »
Table » 

Views:
  1. Creating and Using a View
  2. Creating and Using Simple Views
  3. Performing an INSERT Using a View
  4. A View with a CHECK OPTION Constraint
  5. View with a READ ONLY Constraint
  6. Getting Information on View Definitions with DESCRIBE command
  7. Getting Information on View Definitions with user_views view
  8. Retrieving Information on View Constraints
  9. Creating and Using Complex Views
  10. Modifying a View
  11. Alter the constraints on a view using ALTER VIEW
  12. Dropping a View
Related: