You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The database object name is referred to as its identifier. Everything in [!INCLUDE [ssNoVersion](../../includes/ssnoversion-md.md)] can have an identifier. Servers, databases, and database objects, such as tables, views, columns, indexes, triggers, procedures, constraints, and rules, can have identifiers. Identifiers are required for most objects, but are optional for some objects such as constraints.
29
+
The database object name is referred to as its identifier.
30
30
31
-
An object identifier is created when the object is defined. The identifier is then used to reference the object. For example, the following statement creates a table with the identifier `TableX`, and two columns with the identifiers `KeyCol` and `Description`:
31
+
Servers, databases, and database objects, such as tables, views, columns, indexes, triggers, procedures, constraints, and rules, can have identifiers. Most objects require identifiers, but some objects, such as constraints, make them optional.
32
+
33
+
You create an object identifier when you define the object. Use the identifier to reference the object. For example, the following statement creates a table with the identifier `TableX`, and two columns with the identifiers `KeyCol` and `Description`:
32
34
33
35
```sql
34
36
CREATETABLETableX (
@@ -37,11 +39,14 @@ CREATE TABLE TableX (
37
39
);
38
40
```
39
41
40
-
This table also has an unnamed constraint. The `PRIMARY KEY` constraint has no identifier.
42
+
This table also has an unnamed constraint. The primary key constraint has no identifier, and so would be assigned a system-generated name like `PK__TableX__D7CB9CCCEEF0806C`, which you could observe in system metadata views like `sys.key_constraints`.
43
+
44
+
Constraint names and other schema-scoped objects must be unique within a database schema. For example, two primary key constraints can't share a name. However, column names only need to be unique within each table, not within the schema.
41
45
42
-
Some identifiers, such as constraint names and other schema-scoped objects, must be unique within a database schema. For example, two primary key constraints can't share a name. However, column names only need to be unique within each table, not within the schema.
46
+
The collation of an identifier depends on the level at which you define it.
43
47
44
-
The collation of an identifier depends on the level at which it's defined. Identifiers of instance-level objects, such as logins and database names, are assigned the default collation of the instance. Identifiers of objects in a database, such as tables, views, and column names, are assigned the default collation of the database. For example, two tables with names that differ only in case can be created in a database that has case-sensitive collation, but can't be created in a database that has case-insensitive collation.
48
+
- The default collation of the instance is assigned to identifiers of instance-level objects, such as logins and database names.
49
+
- The default collation of the database is assigned to identifiers of objects in a database, such as tables, views, and column names. For example, you can create two tables with names that differ only in case in a database that has case-sensitive collation, but you can't create them in a database that has case-insensitive collation.
45
50
46
51
> [!NOTE]
47
52
> The names of variables, or the parameters of functions and stored procedures must comply with the rules for [!INCLUDE [tsql](../../includes/tsql-md.md)] identifiers.
@@ -103,17 +108,17 @@ Both regular and delimited identifiers must contain from 1 through 128 character
103
108
104
109
## Rules for regular identifiers
105
110
106
-
The names of variables, functions, and stored procedures must comply with the following rules for [!INCLUDE [tsql](../../includes/tsql-md.md)] identifiers.
111
+
The names of variables, functions, and stored procedures must follow these rules for [!INCLUDE [tsql](../../includes/tsql-md.md)] identifiers.
107
112
108
-
1. The first character must be one of the following items:
113
+
1. The first character must be one of the following characters:
109
114
110
115
- A letter as defined by the Unicode Standard 3.2. The Unicode definition of letters includes Latin characters from `a` through `z`, from `A` through `Z`, and also letter characters from other languages.
111
116
112
117
- The underscore (`_`), at sign (`@`), or number sign (`#`).
113
118
114
119
Certain symbols at the beginning of an identifier have special meaning in [!INCLUDE [ssNoVersion](../../includes/ssnoversion-md.md)]. A regular identifier that starts with the at sign always denotes a local variable or parameter and can't be used as the name of any other type of object. An identifier that starts with a number sign denotes a temporary table or procedure. An identifier that starts with double number signs (`##`) denotes a global temporary object. Although the number sign or double number sign characters can be used to begin the names of other types of objects, we don't recommend this practice.
115
120
116
-
Some [!INCLUDE [tsql](../../includes/tsql-md.md)] functions have names that start with double at signs (`@@`). To avoid confusion with these functions, you shouldn't use names that start with `@@`.
121
+
Some [!INCLUDE [tsql](../../includes/tsql-md.md)] functions have names that start with double at signs (`@@`). To avoid confusion with these functions, don't use names that start with `@@`.
117
122
118
123
1. Subsequent characters can include the following list:
119
124
@@ -123,42 +128,26 @@ The names of variables, functions, and stored procedures must comply with the fo
123
128
124
129
- The at sign (`@`), dollar sign (`$`), number sign (`#`), or underscore (`_`).
125
130
126
-
1. The identifier must not be a [!INCLUDE [tsql](../../includes/tsql-md.md)] reserved word. [!INCLUDE [ssNoVersion](../../includes/ssnoversion-md.md)] reserves both the uppercase and lowercase versions of reserved words. When identifiers are used in [!INCLUDE [tsql](../../includes/tsql-md.md)] statements, the identifiers that don't comply with these rules must be delimited by double quotation marks or brackets. The words that are reserved depend on the database compatibility level. This level can be set by using the [ALTER DATABASE compatibility level](../../t-sql/statements/alter-database-transact-sql-compatibility-level.md) statement.
131
+
1. The identifier must not be a [!INCLUDE [tsql](../../includes/tsql-md.md)] reserved word. [!INCLUDE [ssNoVersion](../../includes/ssnoversion-md.md)] reserves both the uppercase and lowercase versions of reserved words. When you use identifiers in [!INCLUDE [tsql](../../includes/tsql-md.md)] statements, delimit identifiers that don't comply with these rules by using double quotation marks or brackets. The words that are reserved depend on the database compatibility level. Set the database compatibility level by using the [ALTER DATABASE compatibility level](../../t-sql/statements/alter-database-transact-sql-compatibility-level.md) statement.
127
132
128
-
1.Embedded spaces or special characters aren't allowed.
133
+
1.Don't use embedded spaces or special characters.
1.Don't use [Supplementary characters](../collations/collation-and-unicode-support.md#Supplementary_Characters).
131
136
132
-
When identifiers are used in [!INCLUDE [tsql](../../includes/tsql-md.md)] statements, the identifiers that don't comply with these rules must be delimited by double quotation marks or brackets.
137
+
When you use identifiers in [!INCLUDE [tsql](../../includes/tsql-md.md)] statements, delimit identifiers that don't comply with these rules by using double quotation marks or brackets.
133
138
134
-
> [!NOTE]
135
-
> Some rules for the format of regular identifiers depend on the database compatibility level. This level can be set by using [ALTER DATABASE compatibility level](../../t-sql/statements/alter-database-transact-sql-compatibility-level.md).
139
+
Some rules for the format of regular identifiers depend on the database compatibility level.
136
140
137
141
## Catalog collation in Azure SQL Database
138
142
139
-
You can't change or set the logical server collation on Azure SQL Database. However, you can configure each database's collations separately for data in the database and for catalog. The catalog collation determines the collation for system metadata, such as object identifiers. Both collations can be specified independently when you [create the database in the Azure portal](/azure/azure-sql/database/single-database-create-quickstart?view=azuresql&preserve-view=true&tabs=azure-portal#create-a-single-database), in T-SQL with [CREATE DATABASE](../../t-sql/statements/create-database-transact-sql.md?view=azuresqldb-current&preserve-view=true#collation_name), in PowerShell with [New-AzSqlDatabase](/powershell/module/az.sql/new-azsqldatabase).
143
+
You can't change or set the logical server collation on Azure SQL Database. However, you can configure each database's collations separately for data in the database and for catalog. The catalog collation determines the collation for system metadata, such as object identifiers. You can specify both collations independently when you [create the database in the Azure portal](/azure/azure-sql/database/single-database-create-quickstart?view=azuresql&preserve-view=true&tabs=azure-portal#create-a-single-database), in T-SQL with [CREATE DATABASE](../../t-sql/statements/create-database-transact-sql.md?view=azuresqldb-current&preserve-view=true#collation_name), or in PowerShell with [New-AzSqlDatabase](/powershell/module/az.sql/new-azsqldatabase).
140
144
141
145
For details and examples, see [CREATE DATABASE](../../t-sql/statements/create-database-transact-sql.md?view=azuresqldb-current&preserve-view=true#collation_name). Specify a collation for the database (`COLLATE`) and a catalog collation for system metadata and object identifiers (`CATALOG_COLLATION`).
142
146
143
147
## Catalog collation in SQL database in Microsoft Fabric
144
148
145
-
You can't change or set the logical server collation on SQL database in Fabric.
146
-
147
-
Currently, by default the collation of a SQL database in Fabric is `SQL_Latin1_General_CP1_CI_AS` and can't be updated. Collations on individual columns are supported.
149
+
Currently, by default the collation of a SQL database in Fabric is `SQL_Latin1_General_CP1_CI_AS`, but this can be configured when deploying. The collation can't be updated after deployment. Collations on individual columns are supported. For more information on deployment options, see [Options to create a SQL database in Fabric](/fabric/database/sql/create-options).
0 commit comments