Creating a View for SELECT
Many views combine data from multiple tables or other views. A view based on multiple tables or other views can be read, but not updated. For example, the following statement creates a read-only view,
PHONE_LIST, because it joins two tables,
EXEC SQL CREATE VIEW PHONE_LIST AS SELECT EMP_NO, FIRST_NAME, LAST_NAME, LOCATION, PHONE_NO FROM EMPLOYEE, DEPARTMENT WHERE EMPLOYEE.DEPT_NO = DEPARTMENT.DEPT_NO; EXEC SQL COMMIT;
- Important: Only a view’s creator initially has access to it. To assign read access to others, use
GRANT. For more information about
GRANT, see “Planning Security” inthe Data Definition Guide.