如何手动禁用表的 CDC?
在为此禁用 CDC 之前我删除了一个表。现在,当我重新创建表并尝试启用 CDC 时,它表示捕获实例已存在。我可以使用不同的捕获实例名称,但需要知道是否可以手动删除关联的捕获实例。
当我通过 SSMS GUI 删除表时,它也会删除 CDC 表。但这次我使用代码删除了该表,并且它没有禁用或删除 CDC。因此就有了麻烦。 Ms 文档讨论了如果更改表被错误删除的热修复。但我已经删除了基表。有关如何删除已删除表的此捕获实例的任何线索?
I dropped a table before disabling CDC for that. Now when I recreated the table and tried enabling CDC it says that capture instance already exists. I can use a different Capture Instance name but need to know if there is anyway to drop the associated capture instance manually.
When I delete a table through SSMS GUI it drops CDC tables too. But this time I dropped the table using code and it didn't disable or remove CDC. Hence the trouble. Ms documentation talks about a hot fix if Change Table are removed by mistake. But I have removed the base table. Any clues on how to remove this capture instance for the dropped table?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
以下是我在 CDC 中删除孤立捕获实例所采取的步骤:
然后运行以下命令:
此时,您应该能够正常通过 sp_cdc_enable_table 重新创建捕获实例。
Here are the steps I took to remove an orphaned capture instance in CDC:
Then run the following:
At that point you should be able to re-create your capture instance via sp_cdc_enable_table as normal.
除了 pdanke 的回复之外,我还必须执行一个步骤:
当我恢复启用了更改数据捕获的数据库时,可能会出现我的 cdc 孤儿。就我而言,
导致其中
source_schema
和source_table
均为NULL
的一个条目。I had to execute one more step in addition to the REPLY by pdanke:
My cdc orphan may have come about when I restored a database where change data capture had been enabled. In my case,
resulted in one entry where
source_schema
andsource_table
were bothNULL
.嗯,我想出了一个办法。我从所有 CDC 系统表中删除了与该表相关的所有记录,并尝试使用相同名称重新创建捕获实例。成功了!
Well I figured out a way. I removed all the records related to that table from all CDC system tables and tried recreating the capture instance with same name. It worked!
很简单
只需使用以下脚本
EXEC sys.sp_cdc_disable_table 'schema_name','Source_Table_Name','CDC_Table_Name'
It's Simple
Just use the following Script
EXEC sys.sp_cdc_disable_table 'schema_name','Source_Table_Name','CDC_Table_Name'