What is a View?
A View is a virtual table created from one or more existing tables using an SQL query.
It does not store data separately.
Instead, it displays data from the original table whenever it is queried.
Why Use a View?
Simplify complex SQL queries
Show only the required columns
Hide sensitive information (salary or password)
Improve security
Make reports easier to create
How Does a View Work?
Student Table
|
CREATE VIEW
|
Student_View
|
SELECT * FROM Student_View;
Syntax:
Create View
CREATE VIEW Student_View AS
SELECT Student_ID, Name, Marks
FROM Student;
Retrieve Data
SELECT * FROM Student_View;
Advantages of Views:
Easy to use
Improves security
Makes reports simple
Reuses SQL queries
Top comments (0)