Creating a View

Syntax

CREATE VIEW view_name AS
SELECT column1, column2, ...
FROM table_name
WHERE condition;

Example

CREATE VIEW employee_view AS
SELECT employee_id, first_name, last_name, salary
FROM employees
WHERE salary > 50000;

Explanation: This creates a view called employee_view that includes only employees with a salary greater than 50,000. The view presents selected columns (employee_id, first_name, last_name, salary) from the employees table.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *