In this example we are going to create a view.
A view is mostly used as a simple way of fetching data from multiple tables.
Example 1:
View with a select on one table.
CREATE OR REPLACE VIEW LessonView AS
SELECT L.*
FROM Lesson L;
Example 2:
View with a select on multiple tables.
CREATE OR REPLACE VIEW ClassRoomLessonView AS
SELECT C.Id,
C.Name,
L.Subject,
L.Teacher
FROM ClassRoom C,
Lesson L
WHERE C.Id = L.ClassRoomId;
To call this views in a query you can use a select statement.
SELECT * FROM LessonView;
SELECT * FROM ClassRoomLessonView;