Sometimes we repeat a certain query over and over - for example "show available books". Instead of writing it each time, we can save it under a name. That is a view (VIEW).
A view is a saved
SELECT query that can be used as if it were an ordinary table. A view stores no data - each time it reaches into the real tables and shows the current result.1CREATE VIEW dostepne_ksiazki AS
2SELECT * FROM ksiazki WHERE dostepna = 1;From now on the Keeper can ask the Library briefly:
1SELECT * FROM dostepne_ksiazki;and will always get a fresh list of books ready to be borrowed, without repeating the condition
WHERE dostepna = 1.1DROP VIEW dostepne_ksiazki;A view is like a ready spyglass on the tower - once set, it always shows what is needed.