Views in SQL

Suryanarayanan
6 min readSep 25, 2023

Views

View is a temporary table created based on the selected columns and rows in a given query. View is a database object which offers security and simplification of complex queries in SQL. All the RDBMS providers support this database object. There are two types of views, they are:

  • Normal Views
  • Materialized Views

In this Blog post, we will learn extensively about the normal views and read here about Materialized views.

Views are used to only deal with SELECT queries. For working with DML queries like DELETE, UPDATE, or INSERT we can use stored procedures.

Benefits of using views:

Security: We can create a separate user / role in database and grant them access to only execute this view.

simplicity: By using a view, we can abstract larger complex select queries.

To follow along with this blog, I recommend you to download and restore the following data in your local database.

Data: https://sds-platform-private.s3-us-east-2.amazonaws.com/uploads/P9-ConsumerComplaints.csv

I am not the owner of the above dataset. The Super Data Science site is the owner of the dataset.

The Scenario

Our company sales team needs to find the products which receives more complaints and they should only access the columns related to the products and not to the customer. But as our table is non-normalized

--

--