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

适用于:Applies to: 是SQL ServerSQL Server(所有支持的版本)yesSQL ServerSQL Server (all supported versions) 是Azure SQL 数据库Azure SQL DatabaseYesAzure SQL 数据库Azure SQL Database 是Azure SQL 托管实例Azure SQL Managed InstanceYesAzure SQL 托管实例Azure SQL Managed Instance 是Azure Synapse AnalyticsAzure Synapse AnalyticsyesAzure Synapse AnalyticsAzure Synapse Analytics 是并行数据仓库Parallel Data Warehouseyes并行数据仓库Parallel Data Warehouse适用于:Applies to: 是SQL ServerSQL Server(所有支持的版本)yesSQL ServerSQL Server (all supported versions) 是Azure SQL 数据库Azure SQL DatabaseYesAzure SQL 数据库Azure SQL Database 是Azure SQL 托管实例Azure SQL Managed InstanceYesAzure SQL 托管实例Azure SQL Managed Instance 是Azure Synapse AnalyticsAzure Synapse AnalyticsyesAzure Synapse AnalyticsAzure Synapse Analytics 是并行数据仓库Parallel Data Warehouseyes并行数据仓库Parallel Data Warehouse

返回有关数据库级事务的信息。Returns information about transactions at the database level.

备注

若要从或调用此 DMV Azure Synapse AnalyticsAzure Synapse Analytics 并行数据仓库Parallel Data Warehouse ,请使用名称 sys.dm_pdw_nodes_tran_database_transactionsTo call this DMV from Azure Synapse AnalyticsAzure Synapse Analytics or 并行数据仓库Parallel Data Warehouse, use the name sys.dm_pdw_nodes_tran_database_transactions.

列名称Column name 数据类型Data type 说明Description
transaction_idtransaction_id bigintbigint 实例级而非数据库级的事务 ID。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。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 2008 及更高版本。Applies to: SQL Server 2008SQL Server 2008 and later.

在事务的数据库中生成的日志记录数。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 2008 及更高版本。Applies to: SQL Server 2008SQL Server 2008 and later.

已复制的事务在数据库中生成的日志记录数。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 2008 及更高版本。Applies to: SQL Server 2008SQL Server 2008 and later.

到目前为止,在事务的数据库日志中使用的字节数。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 2008 及更高版本。Applies to: SQL Server 2008SQL Server 2008 and later.

为事务的数据库日志保留的字节数。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 2008 及更高版本。Applies to: SQL Server 2008SQL Server 2008 and later.

到目前为止,在代表事务的系统事务的数据库日志中使用的字节数。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 2008 及更高版本。Applies to: SQL Server 2008SQL Server 2008 and later.

为代表事务的系统事务的数据库日志保留的字节数。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 2008 及更高版本。Applies to: SQL Server 2008SQL Server 2008 and later.

数据库日志中事务的起始记录的日志序列号 (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 2008 及更高版本。Applies to: SQL Server 2008SQL Server 2008 and later.

数据库日志中最近记录的事务记录的 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 2008 及更高版本。Applies to: SQL Server 2008SQL Server 2008 and later.

数据库日志中事务的最近保存点的 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 2008 及更高版本。Applies to: SQL Server 2008SQL Server 2008 and later.

数据库日志中事务的提交日志记录的 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 2008 及更高版本。Applies to: SQL Server 2008SQL Server 2008 and later.

最近回滚到的 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 2008 及更高版本。Applies to: SQL Server 2008SQL Server 2008 and later.

要撤消的下一个记录的 LSN。LSN of the next record to undo.
pdw_node_idpdw_node_id intint 适用 于: Azure Synapse AnalyticsAzure Synapse Analytics并行数据仓库Parallel Data WarehouseApplies to: Azure Synapse AnalyticsAzure Synapse Analytics, 并行数据仓库Parallel Data Warehouse

此分发所在的节点的标识符。The identifier for the node that this distribution is on.

权限Permissions

在上 SQL ServerSQL Server ,需要 VIEW SERVER STATE 权限。On SQL ServerSQL Server, requires VIEW SERVER STATE permission.
在 SQL 数据库的基本、S0 和 S1 服务目标上,对于弹性池中的数据库, 服务器管理员 帐户或 Azure Active Directory 管理员 帐户是必需的。On SQL Database Basic, S0, and S1 service objectives, and for databases in elastic pools, the server admin account or the Azure Active Directory admin account is required. 对于所有其他 SQL 数据库服务目标, VIEW DATABASE STATE 数据库中需要该权限。On all other SQL Database service objectives, the VIEW DATABASE STATE permission is required in the database.

另请参阅See Also

sys.dm_tran_active_transactions (Transact-sql) sys.dm_tran_active_transactions (Transact-SQL)
sys.dm_tran_session_transactions (Transact-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)