SAND CDBMS SQL Reference Guide
SAND CDBMS SQL Database Objects and Language Elements

 

Previous Topic:
Databases
Chapter Index
Next Topic:
Constraints

 

Views


Views are "virtual tables" defined by a CREATE VIEW statement that specifies a query expression (basically, a SELECT statement) to be executed on one or more tables or views. Unlike standard or "base" tables, a view has no physical existence in the database until it is referenced by an SQL statement, at which point it is generated through execution of its defining SELECT statement. Generally, users perceive views as they would any other table.

Views are typically used either to simplify access to information in the database, or to restrict access to information. For instance, particular users may be given SELECT privileges on a view that is based upon an EMPLOYEE table. The view might contain employee name, department, home address (that is, information sufficient for mailings), and yet not include information considered to be more sensitive, such as social security number, salary, and so on. Unless users have SELECT privileges on the underlying table, they cannot obtain the more sensitive information.

Basic information about views is stored in the same system table as regular tables. The DBA, and users with DBA privileges, can access information about all views in the database by querying the system table SYSTEM.TABLES with the search condition WHERE TYPE='U'OR TYPE='R'. Users without DBA privileges may access basic information about views they own or on which they possess privileges by querying the system view PUBLIC.TABLES with the search condition WHERE TYPE='U'OR TYPE='R'. Users with DBA privileges may access additional information about views by querying the SYSTEM.VIEWTEXT, SYSTEM.VIEWSEM, and SYSTEM.VIEWCOLS. tables. Non-DBA users may query the system view PUBLIC.VIEWTEXT to access the text definitions of views on which they possess some privilege. Refer to Appendix C: SAND CDBMS System Tables/Views for more information about system tables and views.