Let’s create a SampleDB database fist with SQL Management Studio. Now we have to create a table in SampleDB.

Let’s Name the table as – Employee

Now insert data in new Employee table :

Now what is View?
Creates a virtual table whose contents (columns and rows) are defined by a query. Used to hide the complexity of the underlying database schema.

Syntax:

Let’s create a view based on our newly created table:

Let’s alter created view:

Let’s drop altered view:

When to use  View?

  1. To hide the complexity of the underlying database schema, or customize the data and schema for a set of users.
  2. To control access to rows and columns of data.
  3. To aggregate data for performance

Leave a Reply

Your email address will not be published. Required fields are marked *