Have you ever wanted to group a related set of rows of a table and store it somewhere to use later? Well, this is what views are used for.
Views cannot be categorized as real tables, but as a subset of some rows or columns of an existing table.
User access to the entire table can be controlled, and only the rows specified in a view can be displayed.
Users are able to understand the database better, as they do not need to go through the entire table to get the needed data.
It is not necessary for a view to contain data from only one table. Data from different tables can be selected
and joined
in a view.
DML operations (DELETE
, INSERT
, UPDATE
) are not applicable on views.
CREATE View viewname AS query;
CREATE View interviewPrep AS
SELECT *
FROM courses
WHERE kind = 'interview';
DROP View viewname;
DROP View interviewPrep;