Understanding Views
A view is a pseudo-table. In SQL, you can reference a view just like you reference a table in a SELECT statement. You can also use some views with INSERT, UPDATE, and DELETE statements.
Views are a tool of convenience. For example, if you find yourself frequently performing the same join, you might find it more convenient to create a view to use in your queries instead.
Creating a View
You create a view with the CREATE VIEW command. The following example creates a simple view—every column from the customer_contacts table is included, but a WHERE clause restricts the rows returned to only those with the given customer_code.
mysql> CREATE VIEW custview AS -> SELECT * FROM customer_contacts -> WHERE customer_code = 'SCICORP'; ...
Get Sams Teach Yourself MySQL now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.