By : Dhirendra Chauhan
View
• 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.
“In SQL, a view is a virtual table based
on the result-set of an SQL
statement.”
CREATE VIEW Syntax
Syntax
CREATE VIEW view_name AS
SELECT column1, column2, ...
FROM table_name
WHERE condition;
Example
CREATE VIEW abc AS
SELECT Id, Name
FROM Employees
WHERE salary >600;
View
Dropping a View
“A view is deleted with the DROP VIEW command.”
Syntax
DROP VIEW view_name;
Example
DROP VIEW abc;
Updating a View
“A view can be updated with the CREATE OR REPLACE
VIEW command.”
Syntax
CREATE or REPLACE VIEW view_name AS
SELECT column1, column2, ...
FROM table_name
WHERE condition;
CREATE or REPLACE VIEW abc AS
SELECT Id, Name
FROM Employee
WHERE Salary>500;
Example
THANK
YOU

V28 view

  • 1.
  • 2.
    View • A viewcontains rows and columns, just like a real table. • The fields in a view are fields from one or more real tables in the database. “In SQL, a view is a virtual table based on the result-set of an SQL statement.”
  • 3.
    CREATE VIEW Syntax Syntax CREATEVIEW view_name AS SELECT column1, column2, ... FROM table_name WHERE condition; Example CREATE VIEW abc AS SELECT Id, Name FROM Employees WHERE salary >600;
  • 6.
  • 7.
    Dropping a View “Aview is deleted with the DROP VIEW command.” Syntax DROP VIEW view_name; Example DROP VIEW abc;
  • 9.
    Updating a View “Aview can be updated with the CREATE OR REPLACE VIEW command.” Syntax CREATE or REPLACE VIEW view_name AS SELECT column1, column2, ... FROM table_name WHERE condition; CREATE or REPLACE VIEW abc AS SELECT Id, Name FROM Employee WHERE Salary>500; Example
  • 11.