sp_change_log_shipping_secondary_database (Transact-SQL)

适用于:SQL Server

更改辅助数据库设置。

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为,不能为 NULL。

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

0 = 使用 NORECOVERY 还原日志。

1 = 使用 STANDBY 还原日志。

还原 ,不能为 NULL。

[ @disconnect_users = ] 'disconnect_users' 如果设置为 1,则执行还原操作时,用户与辅助数据库断开连接。 默认值 = 0。 disconnect_users ,不能为 NULL。

[ @block_size = ] 'block_size' 用作备份设备的块大小(以字节为单位)。 block_size的默认值为 -1。

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

[ @max_transfer_size = ] 'max_transfer_size' SQL Server 向备份设备发出的最大输入或输出请求的大小(以字节为单位)。 max_transfersizeint ,可以为 NULL。

[ @restore_threshold = ] 'restore_threshold' 在生成警报之前,允许在还原操作之间运行分钟数。 restore_threshold为 int,不能为 NULL。

[ @threshold_alert = ] 'threshold_alert' 超出还原阈值时要引发的警报。 threshold_alertint,默认值为 14421。

[ @threshold_alert_enabled = ] 'threshold_alert_enabled'指定在超过restore_threshold是否引发警报。 1 = 启用;0 = 禁用。 threshold_alert_enabled为,不能为 NULL。

[ @history_retention_period = ] 'history_retention_period' 历史记录将保留的时间长度(以分钟为单位)。 history_retention_period为 int。如果未指定值,将使用值 1440。

返回代码值

0(成功)或 1(失败)

结果集

注解

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

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

  2. 如有必要,使用提供的自变量更改 辅助服务器上log_shipping_monitor_secondary 中的本地监视器记录。

权限

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

示例

此示例演示如何使用 sp_change_log_shipping_secondary_database 更新数据库 LogShipAdventureWorks 的辅助数据库参数。

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

另请参阅

关于日志传送 (SQL Server)
系统存储过程 (Transact-SQL)