经过修改的功能(包含数据库)Modified Features (Contained Database)

适用对象:是SQL Server 否Azure SQL 数据库 否Azure Synapse Analytics (SQL DW) 否并行数据仓库 APPLIES TO: yesSQL Server noAzure SQL Database noAzure Synapse Analytics (SQL DW) noParallel Data Warehouse

为了获得部分包含的数据库的支持,已对以下功能进行了修改。The following features have been modified to be supported by a partially contained database. 经常会对功能进行修改,以便它们不会超出数据库范围。Features are usually modified so they do not cross the database boundary.

有关详细信息,请参阅 Contained DatabasesFor more information, see Contained Databases.

ALTER DATABASEALTER DATABASE

应用程序级别Application Level

在包含数据库内部使用 ALTER DATABASE 语句时,其语法不同于用于非包含数据库的语法。When using the ALTER DATABASE statement from inside of a contained database, the syntax differs from that used for a non-contained database. 这种差异包括对语句元素的限制超出了数据库级别而作用于实例。This difference includes restrictions of elements of the statement that extend beyond the database to the instance. 有关详细信息,请参阅 ALTER DATABASE (Transact-SQL)For more information, see ALTER DATABASE (Transact-SQL).

实例级别Instance Level

在包含数据库外部使用时,ALTER DATABASE 的语法与用于非包含数据库时不同。The syntax for the ALTER DATABASE when used outside of a contained database differs from that used for non-contained databases. 这些更改可防止超出数据库范围。These changes prevent crossing the database boundary. 有关详细信息,请参阅 ALTER DATABASE (Transact-SQL)For more information, see ALTER DATABASE (Transact-SQL).

CREATE DATABASECREATE DATABASE

包含数据库的 CREATE DATABASE 语法与非包含数据库的不同。The CREATE DATABASE syntax for a contained database differs from that for a non-contained database. 有关新的语法要求和考虑事项的信息,请参阅 CREATE DATABASE (SQL Server Transact-SQL)See CREATE DATABASE (SQL Server Transact-SQL)for information about new syntax requirements and allowances.

临时表Temporary Tables

包含数据库中允许使用局部临时表,但它们的行为不同于非包含数据库中的局部临时表。Local temporary tables are permitted within a contained database, but their behavior differs from those in non-contained databases. 在非包含数据库中,临时表数据是按照 tempdb的排序规则调整的。In non-contained databases, temporary table data is collated in the collation of tempdb. 在包含数据库中,临时表数据是按照包含数据库的排序规则调整的。In a contained database temporary table data is collated in the collation of the contained database.

与临时表相关联的所有元数据(例如表名称和列名称、索引等)将在目录排序规则中。All metadata associated with temporary tables (for example, table and column names, indexes, and so on) will be in the catalog collation.

命名约束可能不在临时表中使用。Named constraints may not be used in temporary tables.

临时表可能不引用用户定义类型、XML 架构集合或用户定义函数。Temporary tables may not refer to user-defined types, XML schema collections, or user-defined functions.

排序规则Collation

非包含的数据库模型中有三种不同的排序规则:数据库排序规则、实例排序规则和 tempdb 排序规则。In the non-contained database model, there are three separate types of collation: Database collation, Instance collation, and tempdb collation. 包含数据库只使用两种排序规则:数据库排序规则和新目录排序规则。Contained databases use only two collations, database collation and the new catalog collation. 有关包含数据库排序规则的详细信息,请参阅 Contained Database CollationsSee Contained Database Collations for more details on contained database collation.

用户选项User Options

启用包含数据库时,对于 的实例而言, user options Option SQL ServerSQL Server必须设置为 0。When enabling contained databases, the user options Option must be set to 0 for the instance of SQL ServerSQL Server.

另请参阅See Also

包含数据库的排序规则 Contained Database Collations
包含的数据库Contained Databases