Monitor the running status of database things and database things

Source: Internet
Author: User

Monitor the running status of database things and database things

Select dbt. DATABASE_ID, DB_NAME (DBT. DATABASE_ID) 'database name', DBT. TRANSACTION_ID,. NAME,. TRANSACTION_BEGIN_TIME, case. TRANSACTION_TYPE WHEN 1 then' read/write TRANSACTION 'when 2 then' read-only TRANSACTION 'when 3 then' system TRANSACTION 'when 4 then' Distributed TRANSACTION 'end' TRANSACTION type', case. TRANSACTION_STATE WHEN 0 then' the transaction has not fully initialized the 'when 1 then' transaction has been initialized, but the 'when 2 then' transaction has not been started. The transaction is active and the 'when 3 then' transaction has ended. This status is used by the read-only transaction 'when 4 then'. The commit process 'when 5 then' has been started for the Distributed Transaction. The transaction is in the ready state and waiting for parsing 'when 6 then'. The transaction has been committed. 7 then' the TRANSACTION is rolling back 'when 8 then' the TRANSACTION has rolled back 'end' TRANSACTION status ', ST. SESSION_ID, TT. text as 'Statement recently executed ', ES. PROGRAM_NAME from sys. DM_TRAN_DATABASE_TRANSACTIONS dbtleft join sys. DM_TRAN_ACTIVE_TRANSACTIONS at on dbt. TRANSACTION_ID =. TRANSACTION_IDLEFT join sys. DM_TRAN_SESSION_TRANSACTIONS st on. TRANSACTION_ID = ST. TRANSACTION_IDLEFT join sys. DM_EXEC_SESSIONS es on st. SESSION_ID = ES. SESSION_IDLEFT join sys. DM_EXEC_CONNECTIONS ec on es. SESSION_ID = EC. SESSION_IDOUTER apply sys. DM_EXEC_ SQL _TEXT (EC. MOST_RECENT_ SQL _HANDLE) TTWHERE ST. SESSION_ID> = 50 AND DATABASE_ID <> 32767

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.