Creating a View
- A view is a stored query that acts as a virtual table.
- Construct a view with the "CREATE VIEW" SQL command:
test=> CREATE VIEW emp_F AS SELECT employee_id AS id,
first_name AS private_name, last_name AS family_name FROM employees
WHERE last_name LIKE 'F%' \g
CREATE
test=>
test=> SELECT * FROM emp_F \g
id|private_name|family_name
--+------------+-----------
1|Shlomi |Fish
23|Sarah |Ferguson
26|Falk |Fish
24|Michael |Faraday
71|Tamar |Fish
(5 rows)
- Note: At the moment, PostgreSQL views are read-only.