Find last query executed by specific user in Snowflake

Article for: Amazon Redshift Teradata Vertica

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

Notes

Function used in this query return query activity within the last 7 days and maximum 100 of them. To watch other users queries you need to have MONITOR privilege on these users.

Query

select query_text,
       warehouse_name,
       database_name,
       schema_name,
       user_name,
       role_name,
       execution_status,
       error_code,
       error_message,
       start_time,
       end_time
from table(information_schema.QUERY_HISTORY_BY_USER('USERNAME')) -- put username here
order by start_time desc;

Columns

  • query_text - most recent query text
  • warehouse_name - name of warehouse in which query was executed
  • database_name - name of database in which query was executed
  • schema_name - name of schema in which query was executed
  • user_name - name of user who executed query
  • role_name - role name of user who executed query
  • execution_status - current status of executed query
  • error_code - error code, if the query returned an error
  • error_message - error message, if the query returned an error
  • start_time - start time of query
  • end_time - end time of query

Rows

  • One row represents one query executed by specific user
  • Scope of rows: maximum last 100 queries executed by specific user in last 7 days
  • Ordered by start time of query

Sample results

sample results

Using Web User Interface

In Web User Interface you can watch last query by clicking on Query tab (1) . To obtain last query excuted by specific user, we need to add filter by clicking on Add a filter (2).

Next, select User type of filter (3) and provide username in select box (4).

The first row shows last query executed by selected user.

Comments are only visible when the visitor has consented to statistics cookies. To see and add comments please accept statistics cookies.
0
There are no comments. Click here to write the first comment.