Skip to content

Commit a7688dc

Browse files
committed
acrolinks
1 parent cd1d0cf commit a7688dc

7 files changed

Lines changed: 18 additions & 21 deletions

docs/relational-databases/system-tables/cdc-capture-instance-ct-transact-sql.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,13 @@ ms.assetid: 979c8110-3c54-4e76-953c-777194bc9751
1919
# cdc.<capture_instance>_CT (Transact-SQL)
2020
[!INCLUDE [SQL Server](../../includes/applies-to-version/sql-asdb-asdbmi.md)]
2121

22-
Is the change table created when change data capture is enabled on a source table. The table returns one row for each insert and delete operation performed against the source table, and two rows for each update operation performed against the source table. When the name of the change table is not specified at the time the source table is enabled, the name is derived. The format of the name is cdc.*capture_instance*_CT where *capture_instance* is the schema name of the source table and the source table name in the format *schema_table*. For example, if the table **Person.Address** in the **AdventureWorks** sample database is enabled for change data capture, the derived change table name would be **cdc.Person_Address_CT**.
22+
The change table created when change data capture is enabled on a source table. The table returns one row for each insert and delete operation performed against the source table, and two rows for each update operation performed against the source table. When the name of the change table isn't specified at the time the source table is enabled, the name is derived. The format of the name is cdc.*capture_instance*_CT where *capture_instance* is the schema name of the source table and the source table name in the format *schema_table*. For example, if the table **Person.Address** in the **AdventureWorks** sample database is enabled for change data capture, the derived change table name would be **cdc.Person_Address_CT**.
2323

2424
We recommend that you **do not query the system tables directly**. Instead, execute the [cdc.fn_cdc_get_all_changes_<capture_instance>](../../relational-databases/system-functions/cdc-fn-cdc-get-all-changes-capture-instance-transact-sql.md) and [cdc.fn_cdc_get_net_changes_<capture_instance>](../../relational-databases/system-functions/cdc-fn-cdc-get-net-changes-capture-instance-transact-sql.md) functions.
25-
2625

27-
2826
|Column name|Data type|Description|
2927
|-----------------|---------------|-----------------|
30-
|**__$start_lsn**|**binary(10)**|Log sequence number (LSN) associated with the commit transaction for the change.<br /><br /> All changes committed in the same transaction share the same commit LSN. For example, if a delete operation on the source table removes two rows, the change table will contain two rows, each with the same **__$start_lsn** value.|
28+
|**__$start_lsn**|**binary(10)**|Log sequence number (LSN) associated with the commit transaction for the change.<br /><br /> All changes committed in the same transaction share the same commit LSN. For example, if a delete operation on the source table removes two rows, the change table contains two rows, each with the same **__$start_lsn** value.|
3129
|**__$end_lsn**|**binary(10)**|[!INCLUDE[ssInternalOnly](../../includes/ssinternalonly-md.md)]<br /><br /> In [!INCLUDE[ssSQL11](../../includes/sssql11-md.md)], this column is always NULL.|
3230
|**__$seqval**|**binary(10)**|Sequence value used to order the row changes within a transaction.|
3331
|**__$operation**|**int**|Identifies the data manipulation language (DML) operation associated with the change. Can be one of the following:<br /><br /> 1 = delete<br /><br /> 2 = insert<br /><br /> 3 = update (old values)<br /><br /> Column data has row values before executing the update statement.<br /><br /> 4 = update (new values)<br /><br /> Column data has row values after executing the update statement.|
@@ -37,7 +35,7 @@ ms.assetid: 979c8110-3c54-4e76-953c-777194bc9751
3735

3836
## Remarks
3937

40-
The `__$command_id` column was column was introduced in a cumulative update in versions 2012 through 2016. For version and download information, see KB article 3030352 at [FIX: The change table is ordered incorrectly for updated rows after you enable change data capture for a Microsoft SQL Server database](https://support.microsoft.com/help/3030352/fix-the-change-table-is-ordered-incorrectly-for-updated-rows-after-you). For more information, see [CDC functionality may break after upgrading to the latest CU for SQL Server 2012, 2014 and 2016](/archive/blogs/sql_server_team/cdc-functionality-may-break-after-upgrading-to-the-latest-cu-for-sql-server-2012-2014-and-2016).
38+
The `__$command_id` column was introduced in a cumulative update in versions 2012 through 2016. For version and download information, see KB article 3030352 at [FIX: The change table is ordered incorrectly for updated rows after you enable change data capture for a Microsoft SQL Server database](https://support.microsoft.com/help/3030352/fix-the-change-table-is-ordered-incorrectly-for-updated-rows-after-you). For more information, see [CDC functionality may break after upgrading to the latest CU for SQL Server 2012, 2014 and 2016](/archive/blogs/sql_server_team/cdc-functionality-may-break-after-upgrading-to-the-latest-cu-for-sql-server-2012-2014-and-2016).
4139

4240
## Captured Column Data Types
4341
Captured columns included in this table have the same data type and value as their corresponding source columns with the following exceptions:
@@ -54,7 +52,7 @@ The `__$command_id` column was column was introduced in a cumulative update in v
5452
By default, the maximum size that can be added to a captured column in a single INSERT, UPDATE, WRITETEXT, or UPDATETEXT statement is 65,536 bytes or 64 KB. To increase this size to support larger LOB data, use the [Configure the max text repl size Server Configuration Option](../../database-engine/configure-windows/configure-the-max-text-repl-size-server-configuration-option.md) to specify a larger maximum size. For more information, see [Configure the max text repl size Server Configuration Option](../../database-engine/configure-windows/configure-the-max-text-repl-size-server-configuration-option.md).
5553

5654
## Data Definition Language Modifications
57-
DDL modifications to the source table, such as adding or dropping columns, are recorded in the [cdc.ddl_history](../../relational-databases/system-tables/cdc-ddl-history-transact-sql.md) table. These changes are not applied to the change table. That is, the definition of the change table remains constant. When inserting rows into the change table, the capture process ignores those columns that do not appear in the captured column list associated with the source table. If a column appears in the captured column list that is no longer in the source table, the column is assigned a null value.
55+
DDL modifications to the source table, such as adding or dropping columns, are recorded in the [cdc.ddl_history](../../relational-databases/system-tables/cdc-ddl-history-transact-sql.md) table. These changes aren't applied to the change table. That is, the definition of the change table remains constant. When inserting rows into the change table, the capture process ignores those columns that don't appear in the captured column list associated with the source table. If a column appears in the captured column list that is no longer in the source table, the column is assigned a null value.
5856

5957
Changing the data type of a column in the source table is also recorded in the [cdc.ddl_history](../../relational-databases/system-tables/cdc-ddl-history-transact-sql.md) table. However, this change does alter the definition of the change table. The data type of the captured column in the change table is modified when the capture process encounters the log record for the DDL change made to the source table.
6058

@@ -69,9 +67,9 @@ The `__$command_id` column was column was introduced in a cumulative update in v
6967
## Data Manipulation Language Modifications
7068
When insert, update, and delete operations are performed on a change data capture enabled source table, a record of those DML operations appears in the database transaction log. The change data capture process retrieves information about those changes from the transaction log, and adds either one or two rows to the change table to record the change. Entries are added to the change table in the same order that they were committed to the source table. That said, the commit of change table entries must typically be performed on a group of changes rather than performed per each entry.
7169

72-
An insert operation results in one row added to the change table; a delete operation results in one row added to the change table; if SQL Server implements an update as a "deferred update", which means as a pair of delete and insert operations, the update operation results in two rows added to the change table: the first row reflecting the deletion of the captured data, and the second row reflecting the insertion of the updated, captured data; if SQL Server does not implement an update as a "deferred update", the update operation results in two rows added to the change table: the first row reflecting the captured data before the update, and the second row reflecting the captured data after the update.
70+
An insert operation results in one row added to the change table; a delete operation results in one row added to the change table; if SQL Server implements an update as a "deferred update", which means as a pair of delete and insert operations, the update operation results in two rows added to the change table: the first row reflecting the deletion of the captured data, and the second row reflecting the insertion of the updated, captured data; if SQL Server doesn't implement an update as a "deferred update", the update operation results in two rows added to the change table: the first row reflecting the captured data before the update, and the second row reflecting the captured data after the update.
7371

74-
Within the change table entry, the **__$start_lsn** column is used to record the commit LSN that is associated with the change to the source table, and the **__$seqval column** is used to order the change within its transaction. Together, these metadata columns can be used to make sure that the commit order of the source changes is preserved. Because the capture process obtains its change information from the transaction log, it is important to note that change table entries do not appear synchronously with their corresponding source table changes. Instead, corresponding changes appear asynchronously, after the capture process has processed the relevant change entries from the transaction log.
72+
Within the change table entry, the **__$start_lsn** column is used to record the commit LSN that is associated with the change to the source table, and the **__$seqval column** is used to order the change within its transaction. Together, these metadata columns can be used to make sure that the commit order of the source changes is preserved. Because the capture process obtains its change information from the transaction log, it's important to note that change table entries don't appear synchronously with their corresponding source table changes. Instead, corresponding changes appear asynchronously, after the capture process has processed the relevant change entries from the transaction log.
7573

7674
For insert and delete operations, all the bits in the update mask are set. For update operations, the update mask in both the update old and update new rows will be modified to reflect the columns that changed during update.
7775

docs/relational-databases/system-tables/cdc-captured-columns-transact-sql.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ ms.assetid: 7bb4d408-d764-4ef6-802c-f271c8d39c2a
1919
# cdc.captured_columns (Transact-SQL)
2020
[!INCLUDE [SQL Server](../../includes/applies-to-version/sql-asdb-asdbmi.md)]
2121

22-
Returns one row for each column tracked in a capture instance. By default, all columns of the source table are captured. However, columns can be included or excluded when the source table is enabled for change data capture by specifying a column list. For more information, see [sys.sp_cdc_enable_table &#40;Transact-SQL&#41;](../../relational-databases/system-stored-procedures/sys-sp-cdc-enable-table-transact-sql.md).
22+
Returns one row for each column tracked in a captured instance. By default, all columns of the source table are captured. However, columns can be included or excluded when the source table is enabled for change data capture by specifying a column list. For more information, see [sys.sp_cdc_enable_table &#40;Transact-SQL&#41;](../../relational-databases/system-stored-procedures/sys-sp-cdc-enable-table-transact-sql.md).
2323

2424
We recommend that you **do not query the system tables directly**. Instead, execute the [sys.sp_cdc_get_source_columns](../../relational-databases/system-stored-procedures/sys-sp-cdc-get-captured-columns-transact-sql.md) stored procedure.
2525

@@ -29,7 +29,7 @@ ms.assetid: 7bb4d408-d764-4ef6-802c-f271c8d39c2a
2929
|**column_name**|**sysname**|Name of the captured column.|
3030
|**column_id**|**int**|ID of the captured column within the source table.|
3131
|**column_type**|**sysname**|Type of the captured column.|
32-
|**column_ordinal**|**int**|Column ordinal (1-based) in the change table. The metadata columns in the change table are excluded. Ordinal 1 is assigned to the first captured column.|
32+
|**column_ordinal**|**int**|Column ordinal (one-based) in the change table. The metadata columns in the change table are excluded. Ordinal 1 is assigned to the first captured column.|
3333
|**is_computed**|**bit**|Indicates that the captured column is a computed column in the source table.|
3434

3535
## See Also

docs/relational-databases/system-tables/cdc-change-tables-transact-sql.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,20 @@ ms.assetid: 3525a5f5-8d8b-46a8-b334-4b7cd9fb7c21
1919
# cdc.change_tables (Transact-SQL)
2020
[!INCLUDE [SQL Server](../../includes/applies-to-version/sql-asdb-asdbmi.md)]
2121

22-
Returns one row for each change table in the database. A change table is created when change data capture is enabled on a source table. We recommend that you do not query the system tables directly. Instead, execute the [sys.sp_cdc_help_change_data_capture](../../relational-databases/system-stored-procedures/sys-sp-cdc-help-change-data-capture-transact-sql.md) stored procedure.
22+
Returns one row for each change table in the database. A change table is created when change data capture is enabled on a source table. We recommend that you don't query the system tables directly. Instead, execute the [sys.sp_cdc_help_change_data_capture](../../relational-databases/system-stored-procedures/sys-sp-cdc-help-change-data-capture-transact-sql.md) stored procedure.
2323

2424
|Column name|Data type|Description|
2525
|-----------------|---------------|-----------------|
2626
|**object_id**|**int**|ID of the change table. Is unique within a database.|
2727
|**version**|**int**|[!INCLUDE[ssInternalOnly](../../includes/ssinternalonly-md.md)]<br /><br /> For [!INCLUDE[ssSQL11](../../includes/sssql11-md.md)], this column always returns 0.|
2828
|**source_object_id**|**int**|ID of the source table enabled for change data capture.|
2929
|**capture_instance**|**sysname**|Name of the capture instance used to name instance-specific tracking objects. By default, the name is derived from the source schema name plus the source table name in the format *schemaname_sourcename*.|
30-
|**start_lsn**|**binary(10)**|Log sequence number (LSN) representing the low endpoint when querying for change data in the change table.<br /><br /> NULL = the low endpoint has not been established.|
30+
|**start_lsn**|**binary(10)**|Log sequence number (LSN) representing the low endpoint when querying for change data in the change table.<br /><br /> NULL = the low endpoint hasn't been established.|
3131
|**end_lsn**|**binary(10)**|[!INCLUDE[ssInternalOnly](../../includes/ssinternalonly-md.md)]<br /><br /> For [!INCLUDE[sql2008-md](../../includes/sql2008-md.md)], this column always returns NULL.|
3232
|**supports_net_changes**|**bit**|Support for querying for net changes is enabled for the change table.|
3333
|**has_drop_pending**|**bit**|Capture process has received notification that the source table has been dropped.|
34-
|**role_name**|**sysname**|Name of the database role used to gate access to change data.<br /><br /> NULL = a role is not used.|
35-
|**index_name**|**sysname**|Name of the index used to uniquely identify rows in the source table. **index_name** is either the name of the primary key index of the source table, or the name of a unique index specified when change data capture was enabled on the source table.<br /><br /> NULL = source table did not have a primary key when change data capture was enabled and a unique index was not specified when change data capture was enabled.<br /><br /> Note: If change data capture is enabled on a table where a primary key exists, the change data capture feature uses the index regardless of whether net changes is enabled or not. After change data capture is enabled, no modification is allowed on the primary key. If there is no primary key on the table, you can still enable change data capture but only with net changes set to false. After change data capture is enabled, you can then create a primary key. You can also modify the primary key because change data capture does not use the primary key.|
34+
|**role_name**|**sysname**|Name of the database role used to gate access to change data.<br /><br /> NULL = a role isn't used.|
35+
|**index_name**|**sysname**|Name of the index used to uniquely identify rows in the source table. **index_name** is either the name of the primary key index of the source table, or the name of a unique index specified when change data capture was enabled on the source table.<br /><br /> NULL = source table didn't have a primary key when change data capture was enabled and a unique index wasn't specified when change data capture was enabled.<br /><br /> Note: If change data capture is enabled on a table where a primary key exists, the change data capture feature uses the index regardless of whether net changes are enabled or not. After change data capture is enabled, no modification is allowed on the primary key. If there's no primary key on the table, you can still enable change data capture but only with net changes set to false. After change data capture is enabled, you can then create a primary key. You can also modify the primary key because change data capture doesn't use the primary key.|
3636
|**filegroup_name**|**sysname**|Name of the filegroup in which the change table resides.<br /><br /> NULL = change table is in the default filegroup of the database.|
3737
|**create_date**|**datetime**|Date that the source table was enabled.|
3838
|**partition_switch**|**bit**|Indicates whether the **SWITCH PARTITION** command of **ALTER TABLE** can be executed against a table that is enabled for change data capture. 0 indicates that partition switching is blocked. Non-partitioned tables always return 1.|

docs/relational-databases/system-tables/cdc-ddl-history-transact-sql.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ ms.assetid: cb97ea71-da2f-441a-bbd2-db1f5f48ab49
1919
# cdc.ddl_history (Transact-SQL)
2020
[!INCLUDE [SQL Server](../../includes/applies-to-version/sql-asdb-asdbmi.md)]
2121

22-
Returns one row for each data definition language (DDL) change made to tables that are enabled for change data capture. You can use this table to determine when a DDL change occurred on a source table and what the change was. Source tables that have not had DDL changes will not have entries in this table.
22+
Returns one row for each data definition language (DDL) change made to tables that are enabled for change data capture. You can use this table to determine when a DDL change occurred on a source table and what the change was. Source tables that haven't had DDL changes won't have entries in this table.
2323

24-
We recommend that you do not query the system tables directly. Instead, execute the [sys.sp_cdc_get_ddl_history](../../relational-databases/system-stored-procedures/sys-sp-cdc-get-ddl-history-transact-sql.md) stored procedure.
24+
We recommend that you don't query the system tables directly. Instead, execute the [sys.sp_cdc_get_ddl_history](../../relational-databases/system-stored-procedures/sys-sp-cdc-get-ddl-history-transact-sql.md) stored procedure.
2525

2626
|Column name|Data type|Description|
2727
|-----------------|---------------|-----------------|

0 commit comments

Comments
 (0)