• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
sqlserver tutorial

SQL Server Tutorial

SQL Server Tutorial for Beginners

  • HOME
  • START HERE
  • BASICS
  • ADVANCED
    • Index
    • Views
    • Triggers
    • Stored Procedures
    • User-defined Functions
  • FUNCTIONS

SQL Server Views

Learning Objective

In this tutorial, you will learn what is a view in database, how views are created and used in SQL Server, how to list all the views in SQL Server, renaming a view, removing views from database.

SQL Server Views Introduction

SQL Server view is a virtual table and the content of the view is defined by a query. The query can refer one or more tables or views. Like a table, structure of a view is consist of set of named columns and rows of data. However, view does not store any data physically unless it is indexed. The columns and rows of a view come from the underlying table which are mentioned in the view definition.

Below are the few important point regarding views.

  1. View act as a filter between the data tables and users or applications.
  2. View does not occupy any storage as it does not store any data physically.
  3. Views are made from one or more tables or other views in the same or other databases.
  4. One of the main purpose of the view is to have some security mechanism. Using this, you no need to provide access directly to the underlying table to the user.
  5. Also column and row level security can be achieve using views.
  6. Views can also be used when you copy data to and from SQL Server to improve performance and to partition data.

SQL Server Views Example

Whenever we have to retrieve records which require more than one table, we used to write queries using subquery or joins.

For example, consider we have the following two tables in university schema.

Roll_NoNameAddress
1SagarSiliguri
2SajalKolkata
3ShuvadipDurgapur
4RajatDelhi
5PratikRajkot
6AdityaBangalore
StudentDetails
Roll_NoNameTotal_MarksAge
1Sagar9518
2Sajal6520
3Shuvadip7819
4Rajat7021
5Pratik8922
6Aditya5920
StudentMarks

Managing Views in SQL Server

  • SQL Server Create View
  • SQL Server List Views
  • SQL Server Rename View
  • Check View Definition in SQL Server
  • SQL Server Indexed View
  • Remove View from SQL Server

Primary Sidebar

DATA MANIPULATION

  • SELECT
  • SELECT TOP
  • SELECT DISTINCT
  • OFFSET FETCH
  • ORDER BY
  • GROUP BY
  • BETWEEN
  • LIKE
  • ALIAS
  • HAVING
  • AND
  • OR
  • IN
  • WHERE
  • SELECT INTO
  • INSERT
  • INSERT Multiple rows
  • INSERT INTO SELECT
  • UPDATE
  • DELETE
  • PRIMARY KEY
  • FOREIGN KEY
  • UNIQUE CONSTRAINT
  • NOT NULL CONSTRAINT
  • SUBQUERY
  • CORRELATED SUBQUERY
  • JOINS
  • CROSS JOIN
  • INNER JOIN
  • LEFT JOIN
  • RIGHT JOIN
  • FULL JOIN
  • SELF JOIN
  • UPDATE Join
  • CASE
  • COALESCE
  • NULL
  • NULLIF
  • UNION
  • INTERSECT
  • MERGE
  • EXCEPT
  • EXISTS
  • GROUPING SET
  • PIVOT
  • ROLLUP
  • CUBE

DATA DEFINITION

  • CREATE DATABASE
  • DROP DATABASE
  • CREATE SCHEMA
  • ALTER SCHEMA
  • DROP SCHEMA
  • CREATE TABLE
  • RENAME TABLE
  • DROP TABLE
  • TRUNCATE TABLE
  • IDENTITY column
  • Sequence
  • ALTER TABLE ADD Column
  • ALTER TABLE ALTER Column
  • ALTER TABLE DROP Column

Footer

About

SQLServerTutorial.org provides free tutorials and guide on SQL Server for Developers, Database Administrators, and Solution Architects who want to get started SQL Server quickly.

Recent Posts

  • SQL Server DROP VIEW
  • SQL Server Indexed View
  • Check view definition
  • SQL Server Rename View
  • SQL Server List Views

Quick Links

  • About
  • Contact Us
  • Privacy Policy
  • SQL Server Index
  • SQL Server Views
  • Terms of Use

Copyright © 2023 www.sqlservertutorial.org. All Rights Reserved.