cross db ownership chaining 服务器配置选项cross db ownership chaining Server Configuration Option

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

使用 cross db ownership chaining 选项可以为 MicrosoftMicrosoft SQL ServerSQL Server实例配置跨数据库所有权链接。Use the cross db ownership chaining option to configure cross-database ownership chaining for an instance of MicrosoftMicrosoft SQL ServerSQL Server.

此服务器选项使您能够在数据库级别控制跨数据库所有权链接,或者允许在所有数据库中启用跨数据库所有权链接:This server option allows you to control cross-database ownership chaining at the database level or to allow cross-database ownership chaining for all databases:

  • 如果实例的 cross db ownership chaining 为关(设置为 0),将禁用所有数据库的跨数据库所有权链接。When cross db ownership chaining is off (0) for the instance, cross-database ownership chaining is disabled for all databases.

  • 如果实例的 cross db ownership chaining 为开(设置为 1),将启用所有数据库的跨数据库所有权链接。When cross db ownership chaining is on (1) for the instance, cross-database ownership chaining is on for all databases.

  • 可以使用 ALTER DATABASE 语句的 SET 子句为各个数据库设置跨数据库所有权链接。You can set cross-database ownership chaining for individual databases using the SET clause of the ALTER DATABASE statement. 如果正在创建新的数据库,则可以使用 CREATE DATABASE 语句设置新数据库的跨数据库所有权链接选项。If you are creating a new database, you can set the cross-database ownership chaining option for the new database using the CREATE DATABASE statement.

    建议不要将 cross db ownership chaining 设置为 1,除非 SQL ServerSQL Server 实例所驻留的所有数据库都必须参与跨数据库所有权链接,并且你了解此设置隐含的安全问题。Setting cross db ownership chaining to 1 is not recommended unless all of the databases hosted by the instance of SQL ServerSQL Server must participate in cross-database ownership chaining and you are aware of the security implications of this setting.

若要确定跨数据库所有权链接的当前状态,请执行以下查询:To determine the current status of cross-database ownership chaining, execute the following query:

SELECT is_db_chaining_on, name FROM sys.databases;

结果为 1 指示启用了“跨数据库所有权链接”。A result of 1 indicates that cross-database ownership chaining is enabled.

控制跨数据库所有权链接Controlling Cross-Database Ownership Chaining

在打开或关闭跨数据库所有权链接之前,请注意下列事项:Before turning cross-database ownership chaining on or off, consider the following:

  • 只有 sysadmin 固定服务器角色成员能够启用或禁用跨数据库所有权链接。You must be a member of the sysadmin fixed server role to turn cross-database ownership chaining on or off.

  • 关闭生产服务器的跨数据库所有权链接之前,应全面测试所有应用程序(包括第三方应用程序)以确保更改不会影响应用程序功能。Before turning off cross-database ownership chaining on a production server, fully test all applications, including third-party applications, to ensure that the changes do not affect application functionality.

  • 如果使用 sp_configure 指定 RECONFIGURE,则在服务器运行时可以更改 cross db ownership chaining选项。You can change the cross db ownership chaining option while the server is running if you specify RECONFIGURE with sp_configure.

  • 如果有数据库需要跨数据库所有权链接,建议使用 sp_configure 为实例禁用 cross db ownership chaining选项;然后使用 ALTER DATABASE 语句启用需要此功能的各个数据库的跨数据库所有权链接。If you have databases that require cross-database ownership chaining, the recommended practice is to turn off the cross db ownership chaining option for the instance using sp_configure; then turn on cross-database ownership chaining for individual databases that require it using the ALTER DATABASE statement.

另请参阅See Also

ALTER DATABASE (Transact-SQL) ALTER DATABASE (Transact-SQL)
CREATE DATABASE (SQL Server Transact-SQL) CREATE DATABASE (SQL Server Transact-SQL)
服务器配置选项 (SQL Server) Server Configuration Options (SQL Server)
sp_configure (Transact-SQL) sp_configure (Transact-SQL)
RECONFIGURE (Transact-SQL)RECONFIGURE (Transact-SQL)