如何手动禁用表的 CDC?

发布于 2024-08-13 10:42:30 字数 229 浏览 6 评论 0原文

在为此禁用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

我的黑色迷你裙 2024-08-20 10:42:30

以下是我在 CDC 中删除孤立捕获实例所采取的步骤:

DROP FUNCTION [cdc].[fn_cdc_get_net_changes_dbo_(tablename)]
DROP FUNCTION [cdc].[fn_cdc_get_all_changes_dbo_(tablename)]

然后运行以下命令:

declare @objid int
set @objid = (select object_id from cdc.change_tables where capture_instance = 'your orphaned capture instance')

delete from cdc.index_columns where object_id = @objid
delete from cdc.captured_columns where object_id = @objid
delete from cdc.change_tables where object_id = @objid

此时,您应该能够正常通过 sp_cdc_enable_table 重新创建捕获实例。

Here are the steps I took to remove an orphaned capture instance in CDC:

DROP FUNCTION [cdc].[fn_cdc_get_net_changes_dbo_(tablename)]
DROP FUNCTION [cdc].[fn_cdc_get_all_changes_dbo_(tablename)]

Then run the following:

declare @objid int
set @objid = (select object_id from cdc.change_tables where capture_instance = 'your orphaned capture instance')

delete from cdc.index_columns where object_id = @objid
delete from cdc.captured_columns where object_id = @objid
delete from cdc.change_tables where object_id = @objid

At that point you should be able to re-create your capture instance via sp_cdc_enable_table as normal.

—━☆沉默づ 2024-08-20 10:42:30

除了 pdanke 的回复之外,我还必须执行一个步骤:

DROP TABLE cdc.<capture_insance>_CT

当我恢复启用了更改数据捕获的数据库时,可能会出现我的 cdc 孤儿。就我而言,

EXECUTE sys.sp_cdc_help_change_data_capture 

导致其中 source_schemasource_table 均为 NULL 的一个条目。

I had to execute one more step in addition to the REPLY by pdanke:

DROP TABLE cdc.<capture_insance>_CT

My cdc orphan may have come about when I restored a database where change data capture had been enabled. In my case,

EXECUTE sys.sp_cdc_help_change_data_capture 

resulted in one entry where source_schema and source_table were both NULL.

空城仅有旧梦在 2024-08-20 10:42:30

嗯,我想出了一个办法。我从所有 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!

愿得七秒忆 2024-08-20 10:42:30

很简单

只需使用以下脚本

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'

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文