Views-File
Views-File
Note: This assignment has to be completely performed in MYSQL Workbench. Select your OS
type and download workbench from the given link.
https://dev.mysql.com/downloads/workbench/
● Views in SQL are kind of virtual tables. A View can either have all
the rows of a table or specific rows based on certain condition.
SCHEMA
EVENTS TABLE PARTICIPANT TABLE
CREATING VIEWS
We can create View using CREATE VIEW statement. A View can be created from a
single table or multiple tables.
Syntax:
Q1. Create a view having event name and venue for events having more than 10
participants and venue as center stage.
Output:
Q2. Create a view having event name and venue for events having venue as
auditorium.
YOUR QUERY HERE:
Output:
For creating views from multiple tables, lets create a second table and insert
data.
Create table ‘participant’ having columns,
participant_name,event_name, ,fees_paid_or_not
PARTICIPANT TABLE
Q3. Create a view from events and participant tables having matching event
names.
YOUR QUERY HERE:
Output:
Q4. Create a view of event name and participant name participating in solo
singing event.
Output:
DELETING VIEWS
Syntax:
Output:
UPDATING VIEWS
1. The SELECT statement which is used to create the view should not include GROUP
BY clause or ORDER BY clause.
2. The SELECT statement should not have the DISTINCT keyword.
3. The View should have all NOT NULL values.
4. The view should not be created using nested queries.
5. The view should be created from a single table.
We can use the CREATE OR REPLACE VIEW statement to add or remove fields
from a view.
Syntax:
CREATE OR REPLACE VIEW view_name AS
SELECT column1,coulmn2,..
FROM table_name
WHERE condition;
Q6. Replace the view2 with participant names who have not paid the fees.
Syntax:
INSERT INTO view_name(column1, column2 , column3,..) VALUES(value1, value2,
value3..);
Q7. Insert a row of values in the view2.
YOUR QUERY HERE:
Output:
https://docs.google.com/forms/d/e/1FAIpQLScnAaAKvph9R3vINyCtOOMiav-
tSMsRGlJReMaHyPjsXDlTIA/viewform