Database - SQL for Database Construction - Discussion
Discussion Forum : SQL for Database Construction - General Questions (Q.No. 9)
9.
For what purposes are views used?
Discussion:
1 comments Page 1 of 1.
Fra said:
2 months ago
SQL View is a virtual table based on the result set of an SQL query.
It does not store physical data itself; instead, it dynamically queries the underlying tables whenever called. Views serve several practical purposes in database design and security:
To hide columns (Column-Level Security): You can grant a user access to a view that selects only specific columns (e.g., employee_id, name) while omitting sensitive columns (e.g., salary, ssn) from the base table.
To hide rows (Row-Level Security): By adding a WHERE clause to the view's definition (e.g., WHERE department = 'Sales'), you restrict users to viewing only the rows they are authorised to see.
To hide complicated SQL statements (Abstraction & Simplification): Complex joins, aggregations, subqueries, or business logic can be packaged into a single view.
Users can then query the view with a simple SELECT * FROM view_name; without needing to write or understand the complex underlying query.
It does not store physical data itself; instead, it dynamically queries the underlying tables whenever called. Views serve several practical purposes in database design and security:
To hide columns (Column-Level Security): You can grant a user access to a view that selects only specific columns (e.g., employee_id, name) while omitting sensitive columns (e.g., salary, ssn) from the base table.
To hide rows (Row-Level Security): By adding a WHERE clause to the view's definition (e.g., WHERE department = 'Sales'), you restrict users to viewing only the rows they are authorised to see.
To hide complicated SQL statements (Abstraction & Simplification): Complex joins, aggregations, subqueries, or business logic can be packaged into a single view.
Users can then query the view with a simple SELECT * FROM view_name; without needing to write or understand the complex underlying query.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers