What is view?
Basically, View is the virtual table which is created by the actual table.
Why view?
Sometime we want to perform some task without taking risk of the table so we create separate virtual table of the real table. so that any change of view do not reflect in actual table.
-Also used to join two tables.
Syntax:
CREATE VIEW view_name AS
SELECT columns...
FROM tables
[WHERE conditions];
SELECT * FROM library;
Id |
Stud_name |
Book_Id |
1 |
Aman |
234 |
2 |
Ram |
213 |
3 |
Ramesh |
89 |
4 |
John |
567 |
Now we create a View:
CREATE VIEW temp_library AS SELECT Id,Stud_name FROM library;
SELECT *FROM temp_library;
Id |
Stud_name |
1 |
Aman |
2 |
Ram |
3 |
Ramesh |
4 |
John |