Views in database or any RDBMS are not physical tables. You create views only on base tables. If there are no base tables present, then there is no concept of Views.
Top Rules of Views
- Views are not physical tables.
- Tables are physical tables.
- When physical table is deleted from database the corresponding views will give an error
- You cannot delete records from view since no records present in views -those are present in base tables only
Reasons to Create a View
- Controls access to a table
- Make data easier-to-use
- Simplify authorization by granting access to a view without granting access to the table
- Show only portions of data in the table
- Show summary data for a given table
- Combine two or more tables in meaningful ways
- Show only the selected rows that are pertinent to the process that uses the view
Also read: Instant SQL formatter for Your Projects
Best SQL Queries to Create a View
Example – 1
CREATE VIEW ma_proj AS SELECT * FROM project WHERE substr(projno, 1, 2) = 'MA'
CREATE VIEW ma_proj AS selectprojno, projname, respemp FROM project WHERE substr ( projno, 1, 2 ) = 'MA'