A view is a predefined query on one or more tables. Querying a view is done in the same manner as retrieving from a table. Views don't store rows. Rows are always stored in tables. You can put a complex query into a view and grant users access to the view.
You create a view using
CREATE VIEW:
CREATE [OR REPLACE] VIEW
[{FORCE | NOFORCE}] VIEW view_name
[(alias_name[, alias_name ...])] AS subquery
[WITH {CHECK OPTION | READ ONLY} CONSTRAINT constraint_name];
| Item | Description |
|---|---|
| OR REPLACE | the view replaces an existing view. |
| FORCE | create the view even if the base tables don't exist. |
| NOFORCE | don't create the view if the base tables don't exist. NOFORCE is the default. |
| view_name | the name of the view. |
| alias_name | the name of an alias for an expression in the subquery. |
| subquery | is the subquery that retrieves from the base tables. |
| WITH CHECK OPTION | means that only the rows that would be retrieved by the subquery can be inserted, updated, or deleted. By default, the rows are not checked. |
| constraint_name | the name of the WITH CHECK OPTION or WITH READ ONLY constraint. |
| WITH READ ONLY | means the rows may only read from the base tables. |
Privilege for Views
In order to create a view, the user must have the CREATE VIEW privilege.
GRANT CREATE VIEW TO store;