Friday, February 11, 2011

Designing Advanced Database Objects - Views

A view is simple a SELECT statement that has been given a name and stored in a database. The main advantage of view is that once it's created it acts like a table for any other SELECT statements that you wish to right.

Syntax
 1. Create View

CREATE VIEW view_name AS
SELECT column_name(s)
FROM table_name
WHERE condition

2. Update a View

CREATE OR REPLACE VIEW view_name AS
SELECT column_name(s)
FROM table_name
WHERE condition

3. Drop a View

DROP VIEW view_name

view always shows up-to-date data. The database engine always recreate the data using view's SQL statement, every time a  user queries a view.

Create view 
 










Queries from view












Drop view


No comments:

Post a Comment