sp_change_log_shipping_secondary_database (Transact-SQL)

更改辅助数据库设置。

主题链接图标Transact-SQL 语法约定

语法

sp_change_log_shipping_secondary_database
[ @secondary_database = ] 'secondary_database',
[, [ @restore_delay = ] 'restore_delay']
[, [ @restore_all = ] 'restore_all']
[, [ @restore_mode = ] 'restore_mode']
[, [ @disconnect_users = ] 'disconnect_users']
[, [ @block_size = ] 'block_size']
[, [ @buffer_count = ] 'buffer_count']
[, [ @max_transfer_size = ] 'max_transfer_size']
[, [ @restore_threshold = ] 'restore_threshold'] 
[, [ @threshold_alert = ] 'threshold_alert'] 
[, [ @threshold_alert_enabled = ] 'threshold_alert_enabled'] 
[, [ @history_retention_period = ] 'history_retention_period']

参数

  • [ @restore_delay = ] 'restore_delay'
    在还原给定备份文件前辅助服务器等待的时间(分钟)。restore_delay 的数据类型为 int,且不能为 NULL。默认值为 0。

  • [ @restore_all = ] 'restore_all'
    如果设置为 1,则在运行还原作业时,辅助服务器将还原所有可用的事务日志备份。否则,在还原了一个文件之后它将停止。restore_all 的数据类型为 bit,并且不能是 NULL。

  • [ @restore_mode = ] 'restore_mode'
    辅助数据库的还原模式。

    0 = 使用 NORECOVERY 还原日志。

    1 = 使用 STANDBY 还原日志。

    restore 的数据类型为 bit,且不能为 NULL。

  • [ @disconnect_users = ] 'disconnect_users'
    如果设置为 1,则在执行还原操作时,用户将与辅助数据库断开。默认 = 0。disconnect_users 的数据类型为 bit,并且不能是 NULL。

  • [ @block_size = ] 'block_size'
    用作备份设备的块大小(字节)。block_size 的数据类型为 int,默认值为 -1。

  • [ @buffer_count = ] 'buffer_count'
    备份或还原操作使用的缓冲区总数。buffer_count 的数据类型为 int,默认值为 -1。

  • [ @max_transfer_size = ] 'max_transfer_size'
    由 SQL Server 向备份设备发出的最大输入或输出请求的大小(字节)。max_transfersize 的数据类型为 int,可以为 NULL。

  • [ @restore_threshold = ] 'restore_threshold'
    两次还原操作之间允许的间隔时间(分钟),一旦超过此值,就会生成警报。restore_threshold 的数据类型为 int,且不能为 NULL。

  • [ @threshold_alert = ] 'threshold_alert'
    超过备份阈值时引发的警报。threshold_alert 的数据类型为 int,默认值为 14420。

  • [ @threshold_alert_enabled = ] 'threshold_alert_enabled'
    指定超过 backup_threshold 时是否引发警报。1 = 启用;0 = 禁用。threshold_alert_enabled 的数据类型为 bit,并且不能是 NULL。

  • [ @history_retention_period = ] 'history_retention_period'
    历史记录的保留时间长度(分钟)。history_retention_period 的数据类型为 int。如果未指定值,则使用值 1440。

返回代码值

0(成功)或 1(失败)

结果集

注释

必须从辅助服务器上的数据库运行 sp_change_log_shipping_secondary_database。此存储过程执行以下操作:

  1. 根据需要更改 log_shipping_secondary_database 记录中的设置。

  2. 如果需要,使用所提供的参数更改辅助服务器上的 log_shipping_monitor_secondary 中的本地监视记录。

权限

只有 sysadmin 固定服务器角色的成员才可以运行此过程。

示例

此示例阐释了如何使用 sp_change_log_shipping_secondary_database 更新数据库 LogShipAdventureWorks2008R2 的辅助数据库参数。

EXEC master.dbo.sp_change_log_shipping_secondary_database 
 @secondary_database =  'LogShipAdventureWorks2008R2'
,  @restore_delay = 0
,  @restore_all = 1
,  @restore_mode = 0
,  @disconnect_users = 0
,  @threshold_alert = 14420
,  @threshold_alert_enabled = 1
,  @history_retention_period = 14420