Ad space (banner)
🗄️SQL Lessons
Lesson 10 / 50

Creating a VIEW

This lesson covers creating a VIEW, so a frequently-used SELECT statement becomes something you can reuse. It's for anyone searching "SQL VIEW tutorial" or "what is a SQL view."

A view gives a name to a commonly-used SELECT statement so you can reuse it like a table, without retyping a complex condition every time. Under the hood it's essentially a saved query with a name.

The example creates CREATE VIEW high_scorers AS around a query for "students who scored 80+," and afterward, SELECT * FROM high_scorers; alone fetches that result. Notice how much shorter that is than repeating the full condition every time.

A common early mistake is assuming a view stores actual data — it doesn't. Every time you query a view, the original SELECT runs again behind the scenes, so if the underlying table's data changes, the view's results update automatically too. Defining a view like "just the top-performing students" once means every other query can pull that result with a simple SELECT * FROM view_name, keeping your codebase much easier to follow.

SQL
OUTPUT

💡 The SQL engine may take a few seconds to load the first time you run code.

Ad space (banner)
Ad space (in-article)