Lec - 17
Views
- Virtual tables for sqls(if not specified, won't be stored physically )
- Are created from our base tables
- Whatever we add in base table, is available in view and vice-versa
- Cannot add record from view to base if the view does not contain some field
which has
not null constraint
Use cases
- Providing restricted access to some users
- For better performance of join queries which are executed frequently
- works like cache, once we join some tables we can store it usign a view and
the access
again
Syntax and examples
content_copy
create view <view_name> as <select_query>;
- creating a read only view
content_copy
create view <view_name> as <select_query> with read only;
- creating a view check option
- we create view with some where condition
- and if we try to add data which violated where condition, then it will through some
error
content_copy
create view <view_name> as <select_query with where> with check option;
- when we create a view using a join query, we cannot add data using view