Find last query executed by specific user in Teradata database

Teradata enables you to check last query executed by specific user.

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,
        SessionID,
        QueryID,
        UserName,
        QueryText,
        LockLevel,
        StartTime,
        FirstRespTime,
        ClientID,
        ClientAddr,
        ErrorCode,
        ErrorText,
        TotalIOCount,
        NumResultRows
FROM    DBC.QryLogV
WHERE   UserName = 'dae' -- put username here
ORDER BY    StartTime DESC;

Columns

  • ProcID - process ID of the dispatcher
  • SessionID - session id in which query was executed
  • 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 executed by specific user
  • Scope of rows: all logged queries executed by specific user
  • Ordered by start time of query

Sample results

sample results

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