SQL Views1
SQL Views1
Views in SQL are kind of virtual tables. A view also has rows and columns as
they are in a real table in the database. We can create a view by selecting
fields from one or more tables present in the database. A View can either
have all the rows of a table or specific rows based on certain condition. In
this article we will learn about creating , deleting and updating Views.
Sample Tables:
StudentDetails
StudentMarks
CREATING VIEWS
We can create View using CREATE VIEW statement. A View can be created
from a single table or multiple tables. Syntax:
CREATE VIEW view_name AS
SELECT column1, column2.....
FROM table_name
WHERE condition;
OR
Output:
Inserting a row in a view: We can insert a row in a View in a same way
as we do in a table. We can use the INSERT INTO statement of SQL to
insert a row in a View.
Syntax:
INSERT INTO view_name(column1, column2 , column3,..)
VALUES(value1, value2, value3..);