View introduction in SQL Server and SQL Server View Introduction

Source: Internet
Author: User

View introduction in SQL Server and SQL Server View Introduction

1): view definition

A view is a virtual table defined by a query based on one or more tables. It stores the specific definition of the query, and the view does not contain any data.

A view is essentially different from a data table in operations. A data table stores records. However, a view does not store any records, but stores query statements.

For the same data table, you can create different views based on different user needs.

Ii): Role of views

1): Filter rows in the table.
2): prevent unauthorized users from accessing sensitive data
3): reduce database complexity
4): Abstracts multiple physical data into a logical database.

3): Create a view instance

Copy codeThe Code is as follows:
Create view view_officeinfo -- (view name)
As (select A. Name as project Name, B. A _ Name as city, C. A _ Name as region, D. A _ Name as street from dbo. Office_Info as
Inner join dbo. Base_Area as B on A. CityId = B. A _ ID
Inner join dbo. Base_Area as C on A. AreaId = C. A _ ID
Inner join dbo. Base_Area as D on A. StreetId = D. A _ ID) -- (SQL statement)

Select * from view_officeinfo (view name)

4): delete and modify a view.

Delete:
Copy codeThe Code is as follows:
If exists (select * from sys. objects where name = 'view _ officeinfo ')

Drop view_officeinfo

Modify:
Copy codeThe Code is as follows:
Alter view v_Student as SQL statement

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.