0% found this document useful (0 votes)
90 views

SQL Commands For Views and Triggers

This document discusses SQL commands for views and triggers. It defines a view as a virtual table based on the result set of a SQL query. It describes how to create a view using the CREATE VIEW statement and specify a SELECT query, and how to update and drop a view. Triggers are defined as actions performed due to data changes, but details are not provided. The aim was to implement SQL commands to create, update, and delete views, which was concluded to be successful.

Uploaded by

Aman Baheti
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
90 views

SQL Commands For Views and Triggers

This document discusses SQL commands for views and triggers. It defines a view as a virtual table based on the result set of a SQL query. It describes how to create a view using the CREATE VIEW statement and specify a SELECT query, and how to update and drop a view. Triggers are defined as actions performed due to data changes, but details are not provided. The aim was to implement SQL commands to create, update, and delete views, which was concluded to be successful.

Uploaded by

Aman Baheti
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

lOMoARcPSD|4070615

DBMS Exp7- SQL Commands for views and triggers

Database Management System (University of Mumbai)

StuDocu is not sponsored or endorsed by any college or university


Downloaded by Kaushik Koli ([email protected])
lOMoARcPSD|4070615

EXPERIMENT NO : 07
AIM:​​ ​SQL commands to perform views and triggers.

THEORY:
A view can contain all rows of a table or select rows from a table. A view can be created from one or
many tables which depends on the written SQL query to create a view.
Views, which are a type of virtual tables allow users to do the following −
1)Structure data in a way that users or classes of users find natural or intuitive.
2)Restrict access to the data in such a way that a user can see and (sometimes) modify exactly
what they need and no more.
3)Summarize data from various tables which can be used to generate reports.

SQL CREATE VIEW Statement:

In SQL, a view is a virtual table based on the result-set of an SQL statement.


A view contains rows and columns, just like a real table. The fields in a view are fields from one or more
real tables in the database.
You can add SQL functions, WHERE, and JOIN statements to a view and present the data as if the data
were coming from one single table.
CREATE VIEW Syntax:

CREATE VIEW view_name AS


SELECT column1, column2, ...
FROM table_name
WHERE condition;

Then, we can query the view as follows:

​ ROM​ [​Current​ Product List];


SELECT​ * F

OUTPUT:

TE CMPN1/C2 Jatin Jawale/28

Downloaded by Kaushik Koli ([email protected])


lOMoARcPSD|4070615

SQL Updating a View

You can update a view by using the following syntax:

​ R​ REPLACE V
CREATE​ O ​ IEW​ view_name A
​ S
SELECT​ column1, column2, ...
FROM​ table_name
WHERE​ condition;

OUTPUT:

TE CMPN1/C2 Jatin Jawale/28

Downloaded by Kaushik Koli ([email protected])


lOMoARcPSD|4070615

SQL Dropping a View


You can delete a view with the DROP VIEW command.
SQL DROP VIEW Syntax:

​ IEW​ view_name;
DROP​ V

OUTPUT:
The table will be deleted.

CONCLUSION:

Hence SQL commands to perform views and triggers implemented successfully. We learnt about the
concept of views and triggers and created various views for a table in the database and successfully
executed queries on them.

TE CMPN1/C2 Jatin Jawale/28

Downloaded by Kaushik Koli ([email protected])

You might also like