5 SQL VIEWs
5 SQL VIEWs
Virtual Tables
What.... Why.... How....
SQL VIEWs
A view is a “virtual table”
https://ecomputernotes.com/fundamental/what-is-a-database/advantages-and-disadvantages-of-dbms
SQL VIEWs
A view is a “virtual table”
1. SQL View is like a window through which we see a limited section of the actual table or we
give access to a certain section of the table to a database user. e.g. allowing a user to see or
modify only contact information about the students, the other fields will be hidden from
the user.
1. SQL Views are seen as virtual tables. Views do not contain data of their own. To the user,
the view appears like a table with columns and rows but in reality, the SQL VIEW doesn’t
exists in the database as a stored set of values like a table.
2. The rows and columns that we find in a view are actually the results generated by a SQL
SELECT query that defines the view. The table from where the data is obtained is called the
source table
3. VIEWs are used to restrict access to the database (security purpose) or to hide data
complexity (simplicity in viewing required data).
4. A view is a database object like a table and stored as a SELECT statement in the database.
5. DML operations on a view like INSERT, UPDATE, DELETE affects the data in the original table
upon which the view is based.
SQL VIEWs
A view is a “virtual table”
Different Table Views (windows) created by partitioning the table horizontally, vertically, etc..
View_IT View_MECH
SQL VIEWs
A view is a “virtual table”
Emp_tab
Horizontal VIEW
SQL VIEWs
A view is a “virtual table”
Vertical view
SQL VIEWs
A view is a “virtual table”
A view is updatable if :
• DISTINCT is not specified in the query used to create the view
• The FROM clause specifies only one source table
• The select list doesn’t contain expressions/calculated columns
• The WHERE clause doesn’t include a subquery
• The query doesn’t include a GROUP BY or HAVING
SQL VIEWs
A view is a “virtual table”
Advantages and Disadvantages
• Advantages of views
– Security
– Query simplicity
– Structural simplicity
• Disadvantages of views
– Performance
– Restrictions