Working with views Example:- Create a view of merit students create view meritstudent as select * from student where marks>90; selec...
Working with views
Example:-
- Create a view of merit students
- create view meritstudent as select * from student where marks>90;
- select * from meritstudent;
- Alter view meritstudent as select * from student where marks>85;
- select * from meritstudent;
- Rename view meritstudent execllentview;
- select * from execllentview;
- Drop view execllentview;
Create a new view:
CREATE VIEW [IF NOT EXISTS] view_name
AS
select_statement;
Code language: SQL (Structured Query Language) (sql)
Create a new view with the WITH CHECK OPTION
:
CREATE VIEW [IF NOT EXISTS] view_name
AS select_statement
WITH CHECK OPTION;
Code language: SQL (Structured Query Language) (sql)
Create or replace a view:
CREATE OR REPLACE view_name
AS
select_statement;Drop a view:
DROP VIEW [IF EXISTS] view_name;
Code language: SQL (Structured Query Language) (sql)
Drop multiple views:
DROP VIEW [IF EXISTS] view1, view2, ...;
Code language: SQL (Structured Query Language) (sql)
Rename a view:
RENAME TABLE view_name
TO new_view_name;
Code language: SQL (Structured Query Language) (sql)
COMMENTS