Views and Triggers
Views and Triggers
Views in SQL are a kind of virtual table. A view also has rows and columns like
tables, but a view doesn’t store data on the disk like a table. View defines a customized query
that retrieves data from one or more tables, and represents the data as if it was coming from a
single source.
We can create a view by selecting fields from one or more tables present in the
database. A View can either have all the rows of a table or specific rows based on certain
conditions.
-- Create StudentDetails table
CREATE TABLE StudentDetails (
S_ID INT PRIMARY KEY,
NAME VARCHAR(255),
ADDRESS VARCHAR(255)
);
Parameters:
view_name: Name for the View
table_name: Name of the table
condition: Condition to select rows
To see the data in the View, we can query the view in the same manner as we query a table.
SELECT * FROM DetailsView;