Views in SQL
SQL offers the option of views. Views are virtual tables.
Creating a view
It's very easy to create a view in SQL, since the syntax is very similar to selection but with an additional part:
CREATE VIEW test_view AS SELECT surname, SHA1(surname) FROM `Attendees`
It's common to indent the statement under a view as above, but it is still one single SQL query.
Updating a view
Views can also be updated. Assuming the original data has changed and the view needs to be recreated based on the new data, the following SQL command will replace the current view with the updated information:
CREATE OR REPLACE VIEW test_view AS SELECT surname, SHA1(surname) FROM `Attendees`
CREATE OR REPLACE VIEW will create a view or, if it already exists, replace it.
Removing a view
Views can, obviously, be deleted. Deleting is done with the
DROP VIEW test_view