Right now, are going to utilize CREATE VIEW, fundamentally view can be made from solitary, various tables or we can utilize another view.
At whatever point you have to have an alternate view from your unique table you should simply to make see with your ideal fields. In the example beneath, we have utilized this procedure on our fake information.
Presently, the primary thing we have to do is to, find what we will require in our view. From that point onward, execute a SQL question advising database to make a comparative view.
In our spurious information, we have name and age as our fields, so we advise database to a view having these two fields. We can do this by utilizing the creat_view watchword and afterwards utilize select catchphrase to choose the records to structure the database.
This view will be accessible for us to utilize select inquiry from. Presently yes we can legitimately get those records from the database without making any view yet then every time we have to an intricate question we bring these records yet here all we will do will be do a bring inquiry on the view, much the same as we would accomplish for the tables.
Dummy Data for Test:
Syntax:
CREATE VIEW view_name AS SELECT c1, c2,c3,c4,c5...
FROM table_name WHERE [condition];
Example 1:
CREATE VIEW EMPL_VIEW AS SELECT name, age
FROM 'JustTechReview'.'employee';
SELECT * FROM EMPL_VIEW;
Example 2:
CREATE VIEW EMPLOYE_VIEW AS SELECT name, age
FROM 'JustTechReview'.'employee'
WHERE age IS NULL WITH CHECK OPTION;
SELECT * FROM EMPLOYE_VIEW;
Example 3:
DELETE FROM EMPL_VIEW WHERE age = 23;
SELECT * FROM EMPL_VIEW;