Skip to content

Commit 6cb9ee4

Browse files
authored
Update create-indexed-views.md
1 parent 3ff6b46 commit 6cb9ee4

File tree

1 file changed

+42
-42
lines changed

1 file changed

+42
-42
lines changed

docs/relational-databases/views/create-indexed-views.md

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -33,73 +33,73 @@ ms.workload: "Active"
3333
## <a name="BeforeYouBegin"></a> Before You Begin
3434
The following steps are required to create an indexed view and are critical to the successful implementation of the indexed view:
3535

36-
1. Verify the SET options are correct for all existing tables that will be referenced in the view.
37-
2. Verify that the SET options for the session are set correctly before you create any tables and the view.
38-
3. Verify that the view definition is deterministic.
39-
4. Create the view by using the `WITH SCHEMABINDING` option.
40-
5. Create the unique clustered index on the view.
36+
1. Verify the SET options are correct for all existing tables that will be referenced in the view.
37+
2. Verify that the SET options for the session are set correctly before you create any tables and the view.
38+
3. Verify that the view definition is deterministic.
39+
4. Create the view by using the `WITH SCHEMABINDING` option.
40+
5. Create the unique clustered index on the view.
4141

4242
> [!IMPORTANT]
43-
> When executing DML<sup>1</sup> on a table referenced by a large number of indexed views, or fewer but very complex indexed views, those referenced indexed views will have to be updated as well. As a result, DML query performance can degrade significantly, or in some cases, a query plan cannot even be produced.
44-
> In such scenarios, test your DML queries before production use, analyze the query plan and tune/simplify the DML statement.
45-
>
46-
> <sup>1</sup> Such as UPDATE, DELETE or INSERT operations.
43+
> When executing DML<sup>1</sup> on a table referenced by a large number of indexed views, or fewer but very complex indexed views, those referenced indexed views will have to be updated as well. As a result, DML query performance can degrade significantly, or in some cases, a query plan cannot even be produced.
44+
> In such scenarios, test your DML queries before production use, analyze the query plan and tune/simplify the DML statement.
45+
>
46+
> <sup>1</sup> Such as UPDATE, DELETE or INSERT operations.
4747
4848
### <a name="Restrictions"></a> Required SET Options for Indexed Views
49-
Evaluating the same expression can produce different results in the [!INCLUDE[ssDE](../../includes/ssde-md.md)] when different SET options are active when the query is executed. For example, after the SET option `CONCAT_NULL_YIELDS_NULL` is set to ON, the expression **'**abc**'** + NULL returns the value NULL. However, after `CONCAT_NULL_YIEDS_NULL` is set to OFF, the same expression produces **'**abc**'**.
49+
Evaluating the same expression can produce different results in the [!INCLUDE[ssDE](../../includes/ssde-md.md)] when different SET options are active when the query is executed. For example, after the SET option `CONCAT_NULL_YIELDS_NULL` is set to ON, the expression `'abc' + NULL` returns the value `NULL`. However, after `CONCAT_NULL_YIEDS_NULL` is set to OFF, the same expression produces `'abc'`.
5050

51-
To make sure that the views can be maintained correctly and return consistent results, indexed views require fixed values for several SET options. The SET options in the following table must be set to the values shown in the **Required Value** column whenever the following conditions occur:
51+
To make sure that the views can be maintained correctly and return consistent results, indexed views require fixed values for several SET options. The SET options in the following table must be set to the values shown in the **Required Value** column whenever the following conditions occur:
5252

53-
- The view and subsequent indexes on the view are created.
53+
- The view and subsequent indexes on the view are created.
5454

55-
- The base tables referenced in the view at the time the table is created.
55+
- The base tables referenced in the view at the time the table is created.
5656

57-
- There is any insert, update, or delete operation performed on any table that participates in the indexed view. This requirement includes operations such as bulk copy, replication, and distributed queries.
57+
- There is any insert, update, or delete operation performed on any table that participates in the indexed view. This requirement includes operations such as bulk copy, replication, and distributed queries.
5858

59-
- The indexed view is used by the query optimizer to produce the query plan.
59+
- The indexed view is used by the query optimizer to produce the query plan.
6060

61-
|SET options|Required value|Default server value|Default<br /><br /> OLE DB and ODBC value|Default<br /><br /> DB-Library value|
62-
|-----------------|--------------------|--------------------------|---------------------------------------|-----------------------------------|
63-
|ANSI_NULLS|ON|ON|ON|OFF|
64-
|ANSI_PADDING|ON|ON|ON|OFF|
65-
|ANSI_WARNINGS<sup>1</sup>|ON|ON|ON|OFF|
66-
|ARITHABORT|ON|ON|OFF|OFF|
67-
|CONCAT_NULL_YIELDS_NULL|ON|ON|ON|OFF|
68-
|NUMERIC_ROUNDABORT|OFF|OFF|OFF|OFF|
69-
|QUOTED_IDENTIFIER|ON|ON|ON|OFF|
61+
|SET options|Required value|Default server value|Default<br /><br /> OLE DB and ODBC value|Default<br /><br /> DB-Library value|
62+
|-----------------|--------------------|--------------------------|---------------------------------------|-----------------------------------|
63+
|ANSI_NULLS|ON|ON|ON|OFF|
64+
|ANSI_PADDING|ON|ON|ON|OFF|
65+
|ANSI_WARNINGS<sup>1</sup>|ON|ON|ON|OFF|
66+
|ARITHABORT|ON|ON|OFF|OFF|
67+
|CONCAT_NULL_YIELDS_NULL|ON|ON|ON|OFF|
68+
|NUMERIC_ROUNDABORT|OFF|OFF|OFF|OFF|
69+
|QUOTED_IDENTIFIER|ON|ON|ON|OFF|
7070

71-
<sup>1</sup> Setting `ANSI_WARNINGS` to ON implicitly sets `ARITHABORT` to ON.
71+
<sup>1</sup> Setting `ANSI_WARNINGS` to ON implicitly sets `ARITHABORT` to ON.
7272

73-
If you are using an OLE DB or ODBC server connection, the only value that must be modified is the `ARITHABORT` setting. All DB-Library values must be set correctly either at the server level by using **sp_configure** or from the application by using the SET command.
73+
If you are using an OLE DB or ODBC server connection, the only value that must be modified is the `ARITHABORT` setting. All DB-Library values must be set correctly either at the server level by using **sp_configure** or from the application by using the SET command.
7474

7575
> [!IMPORTANT]
7676
> We strongly recommend that you set the `ARITHABORT` user option to ON server-wide as soon as the first indexed view or index on a computed column is created in any database on the server.
7777
7878
### Deterministic Views
79-
The definition of an indexed view must be deterministic. A view is deterministic if all expressions in the select list, as well as the `WHERE` and `GROUP BY` clauses, are deterministic. Deterministic expressions always return the same result any time they are evaluated with a specific set of input values. Only deterministic functions can participate in deterministic expressions. For example, the `DATEADD` function is deterministic because it always returns the same result for any given set of argument values for its three parameters. `GETDATE` is not deterministic because it is always invoked with the same argument, but the value it returns changes each time it is executed.
79+
The definition of an indexed view must be deterministic. A view is deterministic if all expressions in the select list, as well as the `WHERE` and `GROUP BY` clauses, are deterministic. Deterministic expressions always return the same result any time they are evaluated with a specific set of input values. Only deterministic functions can participate in deterministic expressions. For example, the `DATEADD` function is deterministic because it always returns the same result for any given set of argument values for its three parameters. `GETDATE` is not deterministic because it is always invoked with the same argument, but the value it returns changes each time it is executed.
8080

81-
To determine whether a view column is deterministic, use the **IsDeterministic** property of the [COLUMNPROPERTY](../../t-sql/functions/columnproperty-transact-sql.md) function. To determine if a deterministic column in a view with schema binding is precise, use the **IsPrecise** property of the COLUMNPROPERTY function. COLUMNPROPERTY returns 1 if TRUE, 0 if FALSE, and NULL for input that is not valid. This means the column is not deterministic or not precise.
81+
To determine whether a view column is deterministic, use the **IsDeterministic** property of the [COLUMNPROPERTY](../../t-sql/functions/columnproperty-transact-sql.md) function. To determine if a deterministic column in a view with schema binding is precise, use the **IsPrecise** property of the `COLUMNPROPERTY` function. `COLUMNPROPERTY` returns 1 if TRUE, 0 if FALSE, and NULL for input that is not valid. This means the column is not deterministic or not precise.
8282

83-
Even if an expression is deterministic, if it contains float expressions, the exact result may depend on the processor architecture or version of microcode. To ensure data integrity, such expressions can participate only as non-key columns of indexed views. Deterministic expressions that do not contain float expressions are called precise. Only precise deterministic expressions can participate in key columns and in WHERE or GROUP BY clauses of indexed views.
83+
Even if an expression is deterministic, if it contains float expressions, the exact result may depend on the processor architecture or version of microcode. To ensure data integrity, such expressions can participate only as non-key columns of indexed views. Deterministic expressions that do not contain float expressions are called precise. Only precise deterministic expressions can participate in key columns and in `WHERE` or `GROUP BY` clauses of indexed views.
8484

8585
### Additional Requirements
86-
In addition to the SET options and deterministic function requirements, the following requirements must be met:
86+
In addition to the SET options and deterministic function requirements, the following requirements must be met:
8787

88-
- The user that executes `CREATE INDEX` must be the owner of the view.
88+
- The user that executes `CREATE INDEX` must be the owner of the view.
8989

90-
- When you create the index, the `IGNORE_DUP_KEY` option must be set to OFF (the default setting).
90+
- When you create the index, the `IGNORE_DUP_KEY` option must be set to OFF (the default setting).
9191

92-
- Tables must be referenced by two-part names, *schema***.***tablename* in the view definition.
92+
- Tables must be referenced by two-part names, *schema***.***tablename* in the view definition.
9393

94-
- User-defined functions referenced in the view must be created by using the `WITH SCHEMABINDING` option.
94+
- User-defined functions referenced in the view must be created by using the `WITH SCHEMABINDING` option.
9595

96-
- Any user-defined functions referenced in the view must be referenced by two-part names, *schema***.***function*.
96+
- Any user-defined functions referenced in the view must be referenced by two-part names, *\<schema>***.***\<function>*.
9797

98-
- The data access property of a user-defined function must be `NO SQL`, and external access property must be `NO`.
98+
- The data access property of a user-defined function must be `NO SQL`, and external access property must be `NO`.
9999

100-
- Common language runtime (CLR) functions can appear in the select list of the view, but cannot be part of the definition of the clustered index key. CLR functions cannot appear in the WHERE clause of the view or the ON clause of a JOIN operation in the view.
100+
- Common language runtime (CLR) functions can appear in the select list of the view, but cannot be part of the definition of the clustered index key. CLR functions cannot appear in the WHERE clause of the view or the ON clause of a JOIN operation in the view.
101101

102-
- CLR functions and methods of CLR user-defined types used in the view definition must have the properties set as shown in the following table.
102+
- CLR functions and methods of CLR user-defined types used in the view definition must have the properties set as shown in the following table.
103103

104104
|Property|Note|
105105
|--------------|----------|
@@ -134,12 +134,12 @@ ms.workload: "Active"
134134
- If the view definition contains a `GROUP BY` clause, the key of the unique clustered index can reference only the columns specified in the `GROUP BY` clause.
135135

136136
> [!IMPORTANT]
137-
> Indexed views are not supported on top of temporal queries (queries that use `FOR SYSTEM_TIME` clause)
137+
> Indexed views are not supported on top of temporal queries (queries that use `FOR SYSTEM_TIME` clause).
138138
139139
### <a name="Recommendations"></a> Recommendations
140140
When you refer to **datetime** and **smalldatetime** string literals in indexed views, we recommend that you explicitly convert the literal to the date type you want by using a deterministic date format style. For a list of the date format styles that are deterministic, see [CAST and CONVERT &#40;Transact-SQL&#41;](../../t-sql/functions/cast-and-convert-transact-sql.md). For more information about deterministic and nondeterministic expressions, see the [Considerations](#nondeterministic) section in this page.
141141

142-
When you execute DML (such as UPDATE, DELETE or INSERT) on a table referenced by a large number of indexed views, or fewer but very complex indexed views, those indexed views will have to be updated as well during DML execution. As a result, DML query performance may degrade significantly, or in some cases, a query plan cannot even be produced. In such scenarios, test your DML queries before production use, analyze the query plan and tune/simplify the DML statement.
142+
When you execute DML (such as `UPDATE`, `DELETE` or `INSERT`) on a table referenced by a large number of indexed views, or fewer but very complex indexed views, those indexed views will have to be updated as well during DML execution. As a result, DML query performance may degrade significantly, or in some cases, a query plan cannot even be produced. In such scenarios, test your DML queries before production use, analyze the query plan and tune/simplify the DML statement.
143143

144144
### <a name="Considerations"></a> Considerations
145145
The setting of the **large_value_types_out_of_row** option of columns in an indexed view is inherited from the setting of the corresponding column in the base table. This value is set by using [sp_tableoption](../../relational-databases/system-stored-procedures/sp-tableoption-transact-sql.md). The default setting for columns formed from expressions is 0. This means that large value types are stored in-row.
@@ -157,7 +157,7 @@ When you execute DML (such as UPDATE, DELETE or INSERT) on a table referenced by
157157
### <a name="Security"></a> Security
158158

159159
#### <a name="Permissions"></a> Permissions
160-
Requires CREATE VIEW permission in the database and ALTER permission on the schema in which the view is being created.
160+
Requires **CREATE VIEW** permission in the database and **ALTER** permission on the schema in which the view is being created.
161161

162162
## <a name="TsqlProcedure"></a> Using Transact-SQL
163163

@@ -216,7 +216,7 @@ When you execute DML (such as UPDATE, DELETE or INSERT) on a table referenced by
216216
GO
217217
```
218218

219-
For more information, see [CREATE VIEW &#40;Transact-SQL&#41;](../../t-sql/statements/create-view-transact-sql.md).
219+
For more information, see [CREATE VIEW &#40;Transact-SQL&#41;](../../t-sql/statements/create-view-transact-sql.md).
220220

221221
## See Also
222222
[CREATE INDEX &#40;Transact-SQL&#41;](../../t-sql/statements/create-index-transact-sql.md)

0 commit comments

Comments
 (0)