gpt4 book ai didi

sql-server - 将新列添加到源表后,CDC 表无法工作

转载 作者:行者123 更新时间:2023-12-02 18:40:29 53 4
gpt4 key购买 nike

两个新列已添加到我们的源表中,同时表上仍启用 CDC。我需要新列出现在 CDC 表中,但不知道应遵循什么程序来执行此操作?我已经在表上禁用了 CDC,在数据库上禁用了 CDC,将新列添加到 cdc.captured_columns 表中,并启用了 CDC。但现在我在 CDC 表中没有收到任何数据!

将列添加到源表后是否还必须更新其他一些 CDC 表?这些是系统表文件夹下的所有 CDC 表:

  • cdc.captured_columns <----- 我添加新列的位置
  • cdc.change_tables
  • cdc.dbo_myTable_CT <-------- 捕获更改数据的表
  • cdc.ddl_history
  • cdc.index_columns
  • cdc.lsn_time_mapping
  • dbo.systranschemas

最佳答案

我建议阅读Tracking Changes in Your Enterprise Database 。非常详细和深刻。其他极其有用的信息包括:

DDL changes are unrestricted while change data capture is enabled. However, they may have some effect on the change data collected if columns are added or dropped. If a tracked column is dropped, all further entries in the capture instance will have NULL for that column. If a column is added, it will be ignored by the capture instance. In other words, the shape of the capture instance is set when it is created.

If column changes are required, it is possible to create another capture instance for a table (to a maximum of two capture instances per table) and allow consumers of the change data to migrate to the new table schema.

这是一个非常明智且经过深思熟虑的设计,考虑了架构漂移(并非所有参与者都可以在真正的在线部署中同时更新架构)。采用多阶段方法(部署 DDL、捕获新的 CDC、升级订阅者、放弃旧的 CDC 捕获)是唯一可行的方法,您应该效仿。

关于sql-server - 将新列添加到源表后,CDC 表无法工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14958119/

53 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com