View of SQL Server

Source: Internet
Author: User

Today, we will start with a basic article on the database.ArticleBecause I recently met several SQL developer jobs, I took this opportunity to pick up everything I learned from my school. All right, let's get started.

First, what is view used?

Views allow you to create a virtual representation of table data using a SELECT statement as its definition.

In other words, view isThe virtual representation of the table.

What can view do?

    1. Simplify data access for query writers. (simplified data access)
    2. Managing Security and protecting sensitive data. (permission management and protection of sensitive data)
    3. Grant permissions exclusively to views, rather than to the underlying tables)
    4. Expose only those columns that you wish the end user to see (end users can only see the columns they want to see)
    5. Allow direct data updates. (allow updating data)

The above points are the specific functions of view and SQL Server.

 

View type?

    1. Regular view (in general view, my understanding is the simplest view definition)

      • Do not nest view (for example, call another view with one view)
      • If you try to use stored procedure instead of view (compare with view, the execution plan of this view will be re-compiled every time you access the view)
    2. Indexed view (the view of the index, similar to the table, first defines the common view, and then adds the clustered index and non-clustered index. Note: Only one clustered index can be added)
    3. Distributed partitioned view (Distributed view, which uses Union all to combine several different SQL Server tables to generate a separate table)

View creation syntax

 

Create   View   [ Schema_name. ] View_name [ (Column [, n ] )]
[ With [Encryption ]   [ Schemabinding ]   [ View_metadata ]   [ , N ] ]
As Select_statement
[ With check Option ]  

 

 

For more information about these syntaxes, see this article.Here

 

Note the following rules when creating a view.

The first select expression can only define a maximum of 1024 columns.

The second into, option, compute, compute by, and Other table variables cannot be used.

The third order by clause cannot be used directly unless it is used together with the top clause.

 

Sleepy .... Continue writing tomorrow! To be continued

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.