SQL server 2016 开启 change tracking 捕获变更数据

概述:


前提条件:
1.数据的兼容级别为90及其以上,即为
SELECT name,database_id, compatibility_level,collation_name  ,snapshot_isolation_state,recovery_model,recovery_model_desc
FROM sys.databases;
--查询数据库的兼容级别:
ALTER DATABASE AdventureWorks2012 SET COMPATIBILITY_LEVEL = 120;  

2.
使用快照隔离是帮助确保所有更改跟踪信息保持一致的最简单方式。 因此,我们强烈建议将数据库的快照隔离设为 ON。

开启CT功能:
ALTER DATABASE AdventureWorks2012  
SET CHANGE_TRACKING = ON  
(CHANGE_RETENTION = 2 DAYS, AUTO_CLEANUP = ON) ;
开启表级别的:
ALTER TABLE Person.Contact  
ENABLE CHANGE_TRACKING  
WITH (TRACK_COLUMNS_UPDATED = ON)  

关闭:
ALTER DATABASE AdventureWorks2012  
SET CHANGE_TRACKING = OFF  ;
ALTER TABLE Person.Contact  
DISABLE CHANGE_TRACKING;  



参考文件:
https://docs.microsoft.com/zh-cn/sql/relational-databases/track-changes/about-change-tracking-sql-server?view=sql-server-2017

https://docs.microsoft.com/en-us/sql/relational-databases/track-changes/enable-and-disable-change-tracking-sql-server?view=sql-server-2017

https://docs.microsoft.com/zh-cn/sql/relational-databases/track-changes/work-with-change-tracking-sql-server?view=sql-server-2017

 

你可能感兴趣的:(Linux)