0% found this document useful (0 votes)
6 views2 pages

View

The document discusses how to create, update, and destroy views in SQL. It provides the syntax and descriptions for creating a view to select data from an existing table. Updating a view allows it to be automatically updated from the table. Destroying a view removes it using the drop command. Example questions are provided to create different views based on conditions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

View

The document discusses how to create, update, and destroy views in SQL. It provides the syntax and descriptions for creating a view to select data from an existing table. Updating a view allows it to be automatically updated from the table. Destroying a view removes it using the drop command. Example questions are provided to create different views based on conditions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

VIEWS

CREATING VIEW:
SYNTAX: create view view_name(attributes) as (select query
from existing_table_name);
DESCRIPTION:
Using this command, we can create views from existing table without every
time giving the same condition to check.

Ex:

OUTPUT:

UPDATING VIEW:

SYNTAX: create view view_name(attributes) as (select query from


existing_table_name) with check option;

DESCRIPTION:
This command is similar to create except that at end of the query we add
‘with check option’ which allows the view to get updated automatically from the
table without the programmer to update it with commands explicitly.

Ex:
OUTPUT:

After insert command is used

DESTROYING VIEW:

SYNTAX: drop view view_name;

DESCRIPTION:

Using this command, we can drop the views that we don’t want.

Ex:

OUTPUT:

Exercise Questions:

1. Create a view to store sailor name with a rating >9


2. Create a view to the sailors sid who reserved to boat name called interlake
3. Create a view to store the sailors who have reserved a red or green boat
4. Create a view to store sailors whose rating is better than every sailor called Horatio
5. Create a view to store the name of the sailors who is older than the oldest sailor rating
10

You might also like