SQL Views

SQL views are virtual tables based on the result of an SQL query. They do not store data physically but present data from one or more tables in a simplified or specific format.

Views can be used to:

Tutorials dojo strip
  • Simplify complex queries
  • Present specific columns or filtered data
  • Improve security by limiting access to specific rows or columns

Note: Views are automatically refreshed when queried — no need to manually update the data.

SQL Views Syntax

To create a view, use the following syntax:

SQL

SQL Views Example

The following example creates a view named Brazil_Customers showing only customers from Brazil:

SQL

You can then query the view like a regular table:

SQL

SQL Views Updating a View Example

To update a view, most SQL environments support the CREATE OR REPLACE VIEW syntax:

SQL

Note: The OR REPLACE clause is not supported in our playground.
If you try this in our playground, you’ll get a syntax error.

Workaround for our playground

To “update” a view in our playground, you must first drop the existing view, then create it again:

SQL

This approach ensures compatibility while achieving the same result.

SQL Views Dropping a View Example

To remove a view from the database, use:

SQL

SQL Views Visual Diagram

SQL Views Labs

Tutorials dojo strip