Views: This Reduces Redundant Data On The HDD To A Very Large Extent
A view in SQL is a virtual table based on the result set of an SQL statement. A view contains rows and columns like a real table but derives its data from other tables. Views allow presenting data from multiple tables as if it comes from one table. Views do not store data themselves but rather hold a definition that is used to retrieve data from base tables when the view is referenced. Views are useful for controlling data access and reducing data redundancy.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
23 views11 pages
Views: This Reduces Redundant Data On The HDD To A Very Large Extent
A view in SQL is a virtual table based on the result set of an SQL statement. A view contains rows and columns like a real table but derives its data from other tables. Views allow presenting data from multiple tables as if it comes from one table. Views do not store data themselves but rather hold a definition that is used to retrieve data from base tables when the view is referenced. Views are useful for controlling data access and reducing data redundancy.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 11
Views
• In SQL, a view is a virtual table based on the result-set of an SQL
statement. • 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. • You can add SQL statements and functions to a view and present the data as if the data were coming from one single table. • A view is stored only as a definition in Oracle’s system catalog. When the reference is made to a view, its definition is scanned, the base table is opened and the view is created on top of the base table. • Hence a view holds no data at all, until a specific call to view is The reasons why views are created
When data security is required
When data redundancy is to be kept to the minimum while maintaining data security A query fired on view will run slower than the query fired on the base table CREATE VIEW Syntax CREATE VIEW view_name AS SELECT column1, column2, ...FROM table_name WHERE condition;
Select * from table_name;
Example: CREATE VIEW stu1 AS SELECT roll_no,stu_name FROM stu WHERE city = 'noida'; Following is an example to create a view from the CUSTOMERS table. This view would be used to have customer name and age from the CUSTOMERS table. CREATE VIEW CUSTOMERS_VIEW AS SELECT name, age FROM CUSTOMERS; SELECT * FROM CUSTOMERS_VIEW; Dropping/Deleting Views
Syntax:
DROP VIEW view_name;
Example: DROP VIEW CUSTOMERS_VIEW; SQL update views
TheSQL UPDATE VIEW command can be used
to modify the data of a view. All views are not updatable. So, UPDATE command is not applicable to all views. An updatable view is one which allows performing a UPDATE command on itself without affecting any other table. When can a view be updated? 1. The view is defined based on one and only one table. 2. The view must include the PRIMARY KEY of the table based upon which the view has been created. 3. The view should not have any field made out of aggregate functions. 4. The view must not have any DISTINCT clause in its definition. 5. The view must not have any GROUP BY or HAVING clause in its definition. 6. The view must not have any SUBQUERIES in its definitions. 7. If the view you want to update is based upon another view, the later should be updatable. 8. Any of the selected output fields (of the view) must not use constants, strings or value expressions. Syntax:
UPDATE < view_name >
SET<column1>=<value1>,<column2>=<value2>,..... WHERE <condition>; create view odd_view as select c_id,ordername from odd;