Views (Virtual Tables) in Oracle PLSQL, Assignments of Database Programming

Views (Virtual Tables) in Oracle PLSQL

Typology: Assignments

2021/2022

Available from 03/16/2022

asimahsan45
asimahsan45 🇵🇰

5

(1)

40 documents

1 / 9

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Views (Virtual Tables) in SQL
In this tutorial, you will learn what views are, the different
types available, and the pros and cons of using them.
Database Administrator and Database Users will face two challenges: writing
complex SQL queries and securing database access. Sometimes SQL queries
become more complicated due to the use of multiple joins, subqueries,
and$GROUP BY$in a single query. To simplify such queries, you can use
some proxy over the original table. Also, Sometimes from the security side,
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. Views reduce the complexity of SQL queries and provide secure access
to underlying tables.
In this tutorial, you are going to cover the following topics:
What is View?
Types of Views
Simple View
Complex View
Inline View
Materialized View
Difference Between View and Materialized View
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download Views (Virtual Tables) in Oracle PLSQL and more Assignments Database Programming in PDF only on Docsity!

Views (Virtual Tables) in SQL

In this tutorial, you will learn what views are, the different

types available, and the pros and cons of using them.

Database Administrator and Database Users will face two challenges: writing complex SQL queries and securing database access. Sometimes SQL queries become more complicated due to the use of multiple joins, subqueries, and GROUP BY in a single query. To simplify such queries, you can use some proxy over the original table. Also, Sometimes from the security side, 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. Views reduce the complexity of SQL queries and provide secure access to underlying tables. In this tutorial, you are going to cover the following topics:  What is View?  Types of Views  Simple View  Complex View  Inline View  Materialized View  Difference Between View and Materialized View

 Creating and Dropping a view in SQL  Pros and Cons of Views  Conclusion

What is a 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 views. 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 the 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.

Simple View

Complex View

Inline View

An inline view is a SELECT statement in the FROM-clause of another SELECT statement to create a temporary table that could be referenced by the SELECT statement. Inline views are utilized for writing complex SQL queries without join and subqueries operations. This is called a temporary table because a duplicate copy of the data returned by the stored subquery wasn't stored in the database. In Oracle and in the Postgres community, this temporary table is called an inline view. It is referred to as a subselect.

Comparison Between View and

Materialized View

Creating and Dropping a view in SQL

View can be created and replaced using CREATE VIEW and REPLACE VIEW.

View can be deleted using DROP VIEW command.

Pros and Cons of Views

Views can be utilized as a subset of actual data to perform certain operations. It helps us to provide an abstraction to various users or hide the complexity for users who are accessing data from the table. For example, a user has permission to access particular columns of data rather than the whole table. It can help us to simplify complex queries into a simpler one. It also simplifies data access from multiple joined tables. It can be used as aggregated tables using group by operations. Views can be used for security purposes or can add extra value from the security point of view. It does not hold any space because it only has the definition in the data dictionary, not the copy of actual data. Besides the lots of advantages, views also have some disadvantages such as base table structure dependency, computation time, and restrictions Views have a dependency on the table structure. If you change the table structure, then you have to change the view definition associated with it.

Conclusion

Congratulations, you have made it to the end of this tutorial!