Creating and Dropping a View With SQL

Previous
Previous
Next
Next

To create a database object, such as a view, use the SQL CREATE statement as shown in Example: Creating a View Using SQL. For more information about views, see "Managing Views".

Creating a View Using SQL

-- create a view to display data from departments and employees
CREATE OR REPLACE VIEW my_emp_view AS
SELECT d.department_id, d.department_name, d.manager_id,
  e.employee_id, e.first_name, e.last_name 
  FROM employees e, departments d 
  WHERE d.manager_id = e.employee_id;

Example: Dropping a View Using SQL shows how to drop the view that you previously created.

Dropping a View Using SQL

-- drop the view with the DROP VIEW statement
DROP VIEW my_emp_view;

For information about creating and dropping a view with the Object Browser page, see "Creating a View" and "Dropping a View".