10 Creating Views

In this chapter, you’ll learn how to create and use views. Views are virtual tables based on the output of a query you write to customize the display of your result set. Each time you select from a view, MySQL reruns the query that you defined the view with, returning the latest results as a table-like structure with rows and columns.

Views are useful in situations where you want to simplify a complex query or hide sensitive or irrelevant data.

Creating a New View

You create a view using the create view syntax. Let’s look at an example with the following course table:

course_name course_level --------------------------------------- ...

Get MySQL Crash Course 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.