Find last query executed by specific session in Teradata database

Bart Gawrych - Dataedo Team Bart Gawrych 2019-10-31

Table of Contents:


    Teradata's DBQL enables you to check last query executed.

    To list sessions: List active sessions

    Notes

    To log query information you need to create rules for logs. To do this use BEGIN QUERY LOGGING statement. You can find out how to use it in teradata documentation. Example statement to log all queries:

    BEGIN QUERY LOGGING ON ALL;
    

    Query

    SELECT  ProcID,
            QueryID,
            UserName,
            QueryText,
            LockLevel,
            StartTime,
            FirstRespTime,
            ClientID,
            ClientAddr,
            ErrorCode,
            ErrorText,
            TotalIOCount,
            NumResultRows
    FROM    DBC.QryLogV
    WHERE   SessionID = '1015' -- put session id here
    ORDER BY    StartTime DESC;
    

    Columns

    • ProcID - process ID of the dispatcher
    • QueryID - unique ID to identify the query.
    • UserName - name of the user who executed the query.
    • QueryText - query text. The default size is 200 characters.
    • LockLevel - highest level lock associated with this request
    • StartTime - time the query is submitted
    • FirstRespTime - first response time
    • ClientID - id of client
    • ClientAddr - client address
    • ErrorCode - error code if query fail
    • ErrorText - error text if query fail
    • TotalIOCount - number of IOs from AMPs that were generated by the query
    • NumResultRows - total number of rows returned for the query.

    Rows

    • One row: represents one query
    • Scope of rows: represents last queries executed by specific session
    • Orderer by: query start time, from latest

    Sample results

    sample results

    0
    There are no comments. Click here to write the first comment.

    By continuing to use our website, you consent to the use of cookies in accordance with our Privacy Policy.
    Accept