SQLSERVER CDC 功能

CDC 常用SP:

EXEC sys.sp_cdc_enable_db;
EXEC sys.sp_cdc_enable_table @source_schema= 'dbo', @source_name = 'Patient',@role_name = null ;
--specify database's role to view cdc information, use null to allow all

EXEC sys.sp_cdc_help_change_data_capture; 
--view the table and cdc_instance

EXEC sys.sp_cdc_disable_db;
EXEC Sys.sp_cdc_disable_table @source_schema= 'dbo', @source_name = 'Patient',@capture_instance='dbo_Patient'
--close the table cdc


查询CDC 的结果:

select sys.fn_cdc_map_lsn_to_time(__$start_lsn),* from [cdc].[dbo_Patient_CT]

cdc.captured_columns

为在捕获实例中跟踪的每一列返回一行

sys.sp_cdc_get_source_columns

cdc.change_tables

为数据库中的每个更改表返回一行

sys.sp_cdc_help_change_data_capture

cdc.ddl_history

针对启用了变更数据捕获的表所做的每一数据定义语言 (DDL) 更改返回一行

sys.sp_cdc_get_ddl_history

cdc.lsn_time_mapping

为每个在更改表中存在行的事务返回一行

sys.fn_cdc_map_lsn_to_time (Transact-SQL) ,sys.fn_cdc_map_time_to_lsn (Transact-SQL)

cdc.index_column

为与更改表关联的每一索引列返回一行

sys.sp_cdc_help_change_data_capture

msdb.dbo.cdc_jobs

存储用于捕获和清除作业的变更数据捕获配置参数

NA

cdc.<capture_instance>_CT

对源表启用变更数据捕获时创建的更改表。 该表为对源表执行的每个插入和删除操作返回一行,为对源表执行的每个更新操作返回两行.capture_instance格式=SchameName_TableName

cdc.fn_cdc_get_all_changes_<capture_instance> ,

cdc.fn_cdc_get_net_changes_<capture_instance>

__$start_lsn

binary(10)

更改提交的LSN。在同一事务中提交的更改将共享同一个提交 LSN 值。

__$seqval

binary(10)

一个事务内可能有多个更改发生,这个值用于对它们进行排序。

__$operation

int

更改操作的类型:

1 = 删除

2 = 插入

3 = 更新(捕获的列值是执行更新操作前的值)。

4 = 更新(捕获的列值是执行更新操作后的值)。

__$update_mask

varbinary(128)

位掩码,源表中被CDC跟踪的每一列对应一个位。如果 __$operation = 1 或 2,该值将所有已定义的位设置为 1。如果__$operation = 3 或 4,则只有那些对应已更改列的位设置为 1。



sys.sp_cdc_help_jobs:

job_iduniqueidentifierThe ID of the job.
job_typenvarchar(20)The type of job.
maxtransintThe maximum number of transactions to process in each scan cycle.

maxtrans is valid only for capture jobs.
maxscansintThe maximum number of scan cycles to execute in order to extract all rows from the log.

maxscans is valid only for capture jobs.
continuousbitA flag indicating whether the capture job is to run continuously (1), or run in one-time mode (0). For more information, seesys.sp_cdc_add_job (Transact-SQL).

continuous is valid only for capture jobs.
pollingintervalbigintThe number of seconds between log scan cycles.

pollinginterval is valid only for capture jobs.
retentionbigintThe number of minutes that change rows are to be retained in change tables.

retention is valid only for cleanup jobs.
thresholdbigintThe maximum number of delete entries that can be deleted using a single statement on cleanup.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

爱知菜

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值