SqlServer CDC的使用(OGG)

0    141    1

Tags:

👉 本文共约963个字,系统预计阅读时间或需4分钟。

启用数据库:在当前数据库下执行命令

这个过程会在当前数据库下创建6个系统表
cdc.captured_columns
cdc.change_tables
cdc.ddl_history
cdc.index_columns
cdc.lsn_time_mapping
dbo.systranschemas

2查询哪些数据库启用了CDC功能

启用表,例如表名为”dbo.t1”

注:为第一个表启用CDC后,SQLServer生成两个Agent作业
cdc.dbname_capture
cdc.dbname_cleanup
查看表是否启用了CDC

禁用表(“dbo.t1”)

禁用数据库CDC

一些异常情况的处理

(1) 数据库从2005恢复到2008,打开表级别的附加日志报错
未针对数据库 'AdventureWorks2014' 启用变更数据捕获。 请确保已设置正确的数据库上下文,然后重试该操作。若要报告数据库已启用变更数据捕获这一情况, 请查询 sys.databases 目录视图中的 is_cdc_enabled 列.

解决办法:

本人提供Oracle(OCP、OCM)、MySQL(OCP)、PostgreSQL(PGCA、PGCE、PGCM)等数据库的培训和考证业务,私聊QQ646634621或微信db_bao,谢谢!

CDC表状态的含义:
$operation=2的情况,表示新增
$operation=3或者4,表示更新,3表示旧值,4表示新值
__$operation=1的情况,表示删除

根据发布批量生成表

根据系统表批量生成表

systranschemas (Transact-SQL)

The systranschemas table is used to track schema changes in articles published in transactional and snapshot publications. This table is stored in both publication and subscription databases.

Column nameData typeDescription
tabidintIdentifies the table article on which the schema change occurred.
startlsnbinaryLSN value at the start of the schema change.
endlsnbinaryLSN value at the end of the schema change.
typeidintType of schema change.

标签:

头像

小麦苗

学习或考证,均可联系麦老师,请加微信db_bao或QQ646634621

您可能还喜欢...

发表回复

嘿,我是小麦,需要帮助随时找我哦
  • 18509239930
  • 个人微信

  • 麦老师QQ聊天
  • 个人邮箱
  • 点击加入QQ群
  • 个人微店

  • 回到顶部
返回顶部