您的位置:首页 > 数据库

在某个SQL Server中开启CDC功能

2017-07-04 15:38 381 查看
USE AdventureWorks;

GO

--开启某个数据库的CDC功能

EXEC sys.sp_cdc_enable_db;

GO

--is_cdc_enabled栏位为1代表开启CDC功能了

SELECT name, is_cdc_enabled

FROM sys.databases WHERE database_id = DB_ID();

USE AdventureWorks;

GO

--开启单张表的CDC功能

EXECUTE sys.sp_cdc_enable_table

@source_schema = N’HumanResources’

,@source_name = N’Employee’

,@role_name = N’cdc_Admin’

,@capture_instance = N’HumanResources_Employee’

,@supports_net_changes = 1;

--关闭单张表的CDC功能

EXECUTE sys.sp_cdc_disable_table

@source_schema = N’HumanResources’,

@source_name = N’Employee’,

@capture_instance = N’HumanResources_Employee’;

--检查表是否开启CDC功能

SELECT [name], is_tracked_by_cdc FROM sys.tables

WHERE [object_id] = OBJECT_ID(N’HumanResources.Employee’);

--Alternatively, use the built-in CDC help procedure

EXECUTE sys.sp_cdc_help_change_data_capture

@source_schema = N’HumanResources’,

@source_name = N’Employee’;

GO
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: