IntermediateAdvanced PostgreSQL

Create or Replace View

The query

SQL
CREATE OR REPLACE VIEW active_employees AS
SELECT emp_id, first_name, last_name, dept_id, salary 
FROM employees 
WHERE status = 'active';
Tested against PostgreSQL 16

Note

Allows you to modify a view without dropping it. You can only add columns to the end; you cannot remove columns or change their types.

Tables referenced