千家信息网

[AlwaysOn] 创建SQL Server高可用性组T-SQL语法:DATABASE子句

发表于:2024-11-22 作者:千家信息网编辑
千家信息网最后更新 2024年11月22日,DATABASE database_name指定本地SQL Server实例(即创建可用性组的服务器实例)上一个或多个用户数据库的列表。Specifies a list of one or more
千家信息网最后更新 2024年11月22日[AlwaysOn] 创建SQL Server高可用性组T-SQL语法:DATABASE子句

DATABASE database_name

指定本地SQL Server实例(即创建可用性组的服务器实例)上一个或多个用户数据库的列表。Specifies a list of one or more user databases on the local SQL Server instance (that is, the server instance on which you are creating the availability group). 可以为一个可用性组指定多个数据库,但每个数据库只能属于一个可用性组。You can specify multiple databases for an availability group, but each database can belong to only one availability group. 有关可用性组可以支持的数据库类型的信息,请参阅"永不停机的可用性组(SQL Server)"的前提条件、限制和建议。For information about the type of databases that an availability group can support, see Prerequisites, Restrictions, and Recommendations for Always On Availability Groups (SQL Server). 要找出哪些本地数据库已经属于某个可用性组,请参阅sys.databases目录视图中的replica_id列。To find out which local databases already belong to an availability group, see the replica_id column in the sys.databases catalog view.

DATABASE 子句是可选的。The DATABASE clause is optional. 如果省略了它,则新的可用性组为空。If you omit it, the new availability group is empty.

创建可用性组之后,请连接到承载辅助副本的每个服务器实例,然后准备每个辅助数据库并将其加入到可用性组中。After you have created the availability group, connect to each server instance that hosts a secondary replica and then prepare each secondary database and join it to the availability group. 有关详细信息,请参阅在始终打开的辅助数据库(SQL Server)上启动数据移动。For more information, see Start Data Movement on an Always On Secondary Database (SQL Server).

注释 Note

稍后,您可以在承载当前主副本的服务器实例上向可用性组添加符合条件的数据库。Later, you can add eligible databases on the server instance that hosts the current primary replica to an availability group. 还可以从可用性组中删除数据库。有关详细信息,请参阅alter availability group(Transact-SQL)。You can also remove a database from an availability group. For more information, see ALTER AVAILABILITY GROUP (Transact-SQL).

0