sys.dm_tran_database_transactions (Transact-SQL)sys.dm_tran_database_transactions (Transact-SQL)

適用於: 是SQL Server (從 2008 開始) 是Azure SQL Database 是Azure SQL 資料倉儲 是平行處理資料倉儲 APPLIES TO: yesSQL Server (starting with 2008) yesAzure SQL Database yesAzure SQL Data Warehouse yesParallel Data Warehouse

傳回有關資料庫層級之交易的資訊。Returns information about transactions at the database level.

注意

若要呼叫從這個 DMV Azure SQL 資料倉儲Azure SQL Data Warehouse或是 平行處理資料倉儲Parallel Data Warehouse,使用名稱sys.dm_pdw_nodes_tran_database_transactionsTo call this DMV from Azure SQL 資料倉儲Azure SQL Data Warehouse or 平行處理資料倉儲Parallel Data Warehouse, use the name sys.dm_pdw_nodes_tran_database_transactions.

資料行名稱Column name 資料類型Data type 描述Description
transaction_idtransaction_id bigintbigint 執行個體層級 (而非資料庫層級) 的交易識別碼。ID of the transaction at the instance level, not the database level. 它只有在一個執行個體的所有資料庫才是唯一的,在所有的伺服器執行個體則不是。It is only unique across all databases within an instance, but not unique across all server instances.
database_iddatabase_id intint 與交易相關聯的資料庫識別碼。ID of the database associated with the transaction.
database_transaction_begin_timedatabase_transaction_begin_time datetimedatetime 資料庫變成與交易有關的時間。Time at which the database became involved in the transaction. 尤其,它是資料庫中針對交易的第一筆記錄的時間。Specifically, it is the time of the first log record in the database for the transaction.
database_transaction_typedatabase_transaction_type intint 1 = 讀取/寫入交易1 = Read/write transaction

2 = 唯讀交易2 = Read-only transaction

3 = 系統交易3 = System transaction
database_transaction_statedatabase_transaction_state intint 1 = 交易未初始化。1 = The transaction has not been initialized.

3 = 交易已初始化,但未產生任何記錄。3 = The transaction has been initialized but has not generated any log records.

4 = 交易已產生記錄。4 = The transaction has generated log records.

5 = 已準備交易。5 = The transaction has been prepared.

10 = 已認可交易。10 = The transaction has been committed.

11 = 已回復交易。11 = The transaction has been rolled back.

12 = 正在認可交易。12 = The transaction is being committed. (記錄檔記錄正在產生,但尚未具體化或保存。)(The log record is being generated, but has not been materialized or persisted.)
database_transaction_statusdatabase_transaction_status intint 僅供參考之用。Identified for informational purposes only. 不支援。Not supported. 我們無法保證未來的相容性。Future compatibility is not guaranteed.
database_transaction_status2database_transaction_status2 intint 僅供參考之用。Identified for informational purposes only. 不支援。Not supported. 我們無法保證未來的相容性。Future compatibility is not guaranteed.
database_transaction_log_record_countdatabase_transaction_log_record_count bigintbigint 適用於SQL Server 2008SQL Server 2008SQL Server 2017SQL Server 2017Applies to: SQL Server 2008SQL Server 2008 through SQL Server 2017SQL Server 2017.

在資料庫中針對交易產生的記錄數。Number of log records generated in the database for the transaction.
database_transaction_replicate_record_countdatabase_transaction_replicate_record_count intint 適用於SQL Server 2008SQL Server 2008SQL Server 2017SQL Server 2017Applies to: SQL Server 2008SQL Server 2008 through SQL Server 2017SQL Server 2017.

在資料庫中的交易都會複寫產生的記錄檔記錄數目。Number of log records generated in the database for the transaction that is replicated.
database_transaction_log_bytes_useddatabase_transaction_log_bytes_used bigintbigint 適用於SQL Server 2008SQL Server 2008SQL Server 2017SQL Server 2017Applies to: SQL Server 2008SQL Server 2008 through SQL Server 2017SQL Server 2017.

到目前為止在資料庫記錄中針對交易所使用的位元組數。Number of bytes used so far in the database log for the transaction.
database_transaction_log_bytes_reserveddatabase_transaction_log_bytes_reserved bigintbigint 適用於SQL Server 2008SQL Server 2008SQL Server 2017SQL Server 2017Applies to: SQL Server 2008SQL Server 2008 through SQL Server 2017SQL Server 2017.

在資料庫記錄中針對交易所使用而保留的位元組數。Number of bytes reserved for use in the database log for the transaction.
database_transaction_log_bytes_used_systemdatabase_transaction_log_bytes_used_system intint 適用於SQL Server 2008SQL Server 2008SQL Server 2017SQL Server 2017Applies to: SQL Server 2008SQL Server 2008 through SQL Server 2017SQL Server 2017.

到目前為止在資料庫記錄中針對代表交易之系統交易所使用的位元組數。Number of bytes used so far in the database log for system transactions on behalf of the transaction.
database_transaction_log_bytes_reserved_systemdatabase_transaction_log_bytes_reserved_system intint 適用於SQL Server 2008SQL Server 2008SQL Server 2017SQL Server 2017Applies to: SQL Server 2008SQL Server 2008 through SQL Server 2017SQL Server 2017.

在資料庫記錄中針對代表交易之系統交易所使用而保留的位元組數。Number of bytes reserved for use in the database log for system transactions on behalf of the transaction.
database_transaction_begin_lsndatabase_transaction_begin_lsn numeric(25,0)numeric(25,0) 適用於SQL Server 2008SQL Server 2008SQL Server 2017SQL Server 2017Applies to: SQL Server 2008SQL Server 2008 through SQL Server 2017SQL Server 2017.

資料庫記錄中交易之開始記錄的記錄序號 (LSN)。Log sequence number (LSN) of the begin record for the transaction in the database log.
database_transaction_last_lsndatabase_transaction_last_lsn numeric(25,0)numeric(25,0) 適用於SQL Server 2008SQL Server 2008SQL Server 2017SQL Server 2017Applies to: SQL Server 2008SQL Server 2008 through SQL Server 2017SQL Server 2017.

資料庫記錄中交易之最近記錄的 LSN。LSN of the most recently logged record for the transaction in the database log.
database_transaction_most_recent_savepoint_lsndatabase_transaction_most_recent_savepoint_lsn numeric(25,0)numeric(25,0) 適用於SQL Server 2008SQL Server 2008SQL Server 2017SQL Server 2017Applies to: SQL Server 2008SQL Server 2008 through SQL Server 2017SQL Server 2017.

資料庫記錄中交易之最近儲存點的 LSN。LSN of the most recent savepoint for the transaction in the database log.
database_transaction_commit_lsndatabase_transaction_commit_lsn numeric(25,0)numeric(25,0) 適用於SQL Server 2008SQL Server 2008SQL Server 2017SQL Server 2017Applies to: SQL Server 2008SQL Server 2008 through SQL Server 2017SQL Server 2017.

資料庫記錄中交易之認可記錄的 LSN。LSN of the commit log record for the transaction in the database log.
database_transaction_last_rollback_lsndatabase_transaction_last_rollback_lsn numeric(25,0)numeric(25,0) 適用於SQL Server 2008SQL Server 2008SQL Server 2017SQL Server 2017Applies to: SQL Server 2008SQL Server 2008 through SQL Server 2017SQL Server 2017.

最近回復的 LSN。LSN that was most recently rolled back to. 如果復原已執行,則值會是 MaxLSN。If no rollback has taken place, the value is MaxLSN.
database_transaction_next_undo_lsndatabase_transaction_next_undo_lsn numeric(25,0)numeric(25,0) 適用於SQL Server 2008SQL Server 2008SQL Server 2017SQL Server 2017Applies to: SQL Server 2008SQL Server 2008 through SQL Server 2017SQL Server 2017.

要恢復之下一筆記錄的 LSN。LSN of the next record to undo.
pdw_node_idpdw_node_id intint 適用於: Azure SQL 資料倉儲Azure SQL Data Warehouse平行處理資料倉儲Parallel Data WarehouseApplies to: Azure SQL 資料倉儲Azure SQL Data Warehouse, 平行處理資料倉儲Parallel Data Warehouse

這個分佈是在節點的識別碼。The identifier for the node that this distribution is on.

PermissionsPermissions

[SQL Server]SQL Server,需要VIEW SERVER STATE權限。On [SQL Server]SQL Server, requires VIEW SERVER STATE permission.
SQL DatabaseSQL Database,需要VIEW DATABASE STATE資料庫的權限。On SQL DatabaseSQL Database, requires the VIEW DATABASE STATE permission in the database.

另請參閱See Also

sys.dm_tran_active_transactions (-SQL)) sys.dm_tran_active_transactions (Transact-SQL)
sys.dm_tran_session_transactions (-SQL)) sys.dm_tran_session_transactions (Transact-SQL)
動態管理檢視與函數 (Transact-SQL) Dynamic Management Views and Functions (Transact-SQL)
交易相關的動態管理檢視和函數 (Transact-SQL)Transaction Related Dynamic Management Views and Functions (Transact-SQL)