Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

SIDDHANT BHALLA

19070124062

IT 3

DBMS ASSIGNMENT 10

1. Need of SQL Views

View is the same as a real table for a user with the set of
column names and row data. SQL creates a custom view
by giving the View the same name as a table name and
store a definition of the View in the database.

A view is used for security purposes in the database and


acts as an intermediate between real tables schema and
programmability. It also restricts the user from viewing
specific columns and rows; Views always represent
custom output, which is mentioned in the query and
returns that data defined in the query at the time of
creation.

Features provided by views in SQL are :-


 Security
 Data Integrity
 Consistency
 Data Independence
 Structural Simplicity
 Query Simplicity
2. How to implement and use views in MYSQL.

In MySQL, a VIEW is not a physical table, but rather, it is


in essence a virtual table created by a query joining one
or more tables.
 Syntax for CREATE VIEW

CREATE [OR REPLACE] VIEW view_name AS


SELECT columns
FROM tables
[WHERE conditions];

 Syntax for UPDATE VIEW

You can modify the definition of a VIEW in MySQL


without dropping it by using the ALTER VIEW
statement.

ALTER VIEW view_name AS


SELECT columns
FROM table
WHERE conditions;

 Syntax for DROP VIEW

Once a VIEW has been created in MySQL, you can


drop it with the DROP VIEW statement.

DROP VIEW [IF EXISTS] view_name;


3. Write a view to select all books of SIT library whose cost
is less than 1000

You might also like