×

DBMS Tutorial

DBMS Practice

Views in Database Management System (DBMS)

DBMS Views: In this tutorial, we will about the views in database management systems. what are the views, how views are helpful to see the data and how to create views in DBMS? By Anushree Goswami Last updated : May 26, 2023

DBMS College professor once realized that students feel sad when they see their friend's marks higher than them and it creates a negative impact on them. It gave the Professor an idea to create a view table in his student academic result database.

What is a view?

In the database, View is a virtual table that combines the result set of a stored query. It is very important when we want to restrict a certain user from accessing the entire database. View is dynamic and can be computed from the data in the database. Changing the data in a table alters the data shown in the view as well.

When the Professor applies this technique, the student got to see their marks only and thus create a positive impact on the students as they are now competing with the one person only, themselves.

In a relational database, a view is not the part of a relational schema.

How to create a view?

Syntax to create a view:

create or replace
view view_name
as
select column_name1, column_name2,...
from table_name
where condition;

Example

Suppose, we have to create a student view table of view10.

create
view view10
select marks from student
where rollno = 10;

How to drop a view?

Syntax to drop a view:

drop view viewname;

Example

If view10 table has to be dropped, the command looks like:

drop view view10;

Advantages of a View in DBMS

  1. Views can subset the data in a table.
  2. Views can join and simplify the tables in a virtual table.
  3. Views do not require additional storage.
  4. Views can hide the complexity of the database and the data the user must hide that.
  5. Views can act as aggregated tables where aggregated data (sum, average, etc.) are calculated and presented as part of data.
  6. Views can provide additional security from unauthorized users and unauthorized access.

Disadvantages of a View in DBMS

Database view may be slow if it is approved from a view table that is generated from another view.



Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.