Solution:
Sometimes the database administrator wants to restrict direct access to the database. For example, if a table contains various columns, but the user only needs 3 columns of data in such case DBA will create a virtual table of 3 columns. For both purposes, you can use the view. Views can act as a proxy or virtual table and we can do changes in that table. Views reduce the complexity of SQL queries and provide secure access to underlying tables.
View: Views are a special version of tables in SQL. They provide a virtual table environment for various complex operations. You can select data from multiple tables, or you can select specific data based on certain criteria in view. It does not hold the actual data; it holds only the definition of the view in the data dictionary.
The view is a query stored in the data dictionary, on which the user can query just like they do on tables. It does not use physical memory, only the query is stored in the data dictionary. It is computed dynamically, whenever the user performs any query on it. Changes made at any point in view are reflected in the actual base table.
The view has primarily two purposes:
Types of Views:
Complex View: A view based on multiple tables, which contain GROUP BY clause and functions.
Inline View: A view based on a subquery in FROM Clause, that subquery creates a temporary table and simplifies the complex query.
Materialized View: A view that stores the definition as well as data. It creates replicas of data by storing it physically.
Advantages of views:
Disadvantages of view:
.....
Thanks!
Get Answers For Free
Most questions answered within 1 hours.