SQL Server View Index

Source: Internet
Author: User
Tags sql server books naming convention

Another benefit of creating an index on a view is that the query optimizer begins to use the view index in the query instead of commanding the view directly in the FROM clause. As a result, data can be retrieved from an indexed view without recoding, and the resulting efficiencies also benefit existing queries. The first index created on the view must be a unique clustered index. After you create a unique clustered index, you can create additional nonclustered indexes. The index naming convention on the view is the same as the index naming convention on the table. The only difference is that the table name is replaced by the view name. (SQL Server online Help)
Have not studied, can not say anything to come, now only to write down the method.
Statement:
Create VIEW vxxx with SCHEMABINDING as ...
Create UNIQUE CLUSTERED INDEX idxxxx on vxxx (CXXX)
A standard view that is converted to an indexed view must adhere to the following rules:
A The view must be created with the WITH SCHEMABINDING option;
If you create a view without the with Schemabinding, you will get an error when trying to create a view: ... Because the view is not bound to the schema
B You cannot use other views, export tables, rowset functions, or self-queries in this view, which means you can only use tables;
C The base table used by the view must and the view belong to the same owner;
D Views can only link tables in the same database;
E. A view cannot contain an external link or a self-link, that is, you can only use inner join when linking a table, and you cannot make the same table before or after the inner join, and you cannot use the left or right OUTER join;
F. Views cannot contain a UNION clause, a TOP clause, an ORDER by clause, a HAVING clause, a rollup clause, a cube clause, a Compute clause, a Compute by clause, or a distinct keyword;
G Views do not allow certain aggregate functions, such as: Count (*) can use COUNT_BIG (*) instead, AVG (), Max (), Min (), Stdev (), STDEVP (), Var (), or VarP (), and so on;
H. A view cannot use a statement such as SELECT *, which means that all fields of the view must be specified;
I. Views cannot contain text, ntext, or image types of columns;
J If the view contains a GROUP BY clause, then he must include COUNT_BIG (*) in the Select column;
K All the standard and user-defined functions in the view must be referenced by using the two-segment name, which is the owner. The name of the table or function;
L All basic tables and views must be created using Set ansi_nulls on;
M. When an IUD is executed when an index is created or after an index is created, it must be displayed or implicitly executed:
Set ANSI_NULLS on
SET ansi_padding on
SET ansi_warnings on
SET ARITHABORT on
SET Concat_null_yields_null on
SET QUOTED_IDENTIFIER ON
SET Numeric_roundabort OFF
The information or meaning of each option can be consulted on the SQL Server Books Online, which is no longer covered;
N. Indexed views can only be created in the enterprise or development version of SQL Server2000 or later.

After an indexed view has been created on a table, the delete operation is performed on it: Delete failed because the following set options are incorrect: ' Concat_null_yields_null, Ansi_padding,arithabort ', Removing this view will solve the problem.

SQL Server View Index

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.