Menu
Amazon Redshift
Database Developer Guide (API Version 2012-12-01)

STL_UTILITYTEXT

Captures the text of non-SELECT SQL commands run on the database.

Query the STL_UTILITYTEXT table to capture the following subset of SQL statements that were run on the system:

  • ABORT, BEGIN, COMMIT, END, ROLLBACK

  • CANCEL

  • COMMENT

  • CREATE, ALTER, DROP DATABASE

  • CREATE, ALTER, DROP USER

  • EXPLAIN

  • GRANT, REVOKE

  • LOCK

  • RESET

  • SET

  • SHOW

  • TRUNCATE

See also STL_DDLTEXT, STL_QUERYTEXT, and SVL_STATEMENTTEXT.

Use the STARTTIME and ENDTIME columns to find out which statements were logged during a given time period. Long blocks of SQL text are broken into lines 200 characters long; the SEQUENCE column identifies fragments of text that belong to a single statement.

This table is visible to all users. Superusers can see all rows; regular users can see only their own data. For more information, see Visibility of Data in System Tables and Views.

Table Columns

Column Name Data Type Description
userid integer ID of the user who generated the entry.
xid bigint Transaction ID.
pid integer Process ID associated with the query statement.
label character(30) Either the name of the file used to run the query or a label defined with a SET QUERY_GROUP command. If the query is not file-based or the QUERY_GROUP parameter is not set, this field is blank.
starttime timestamp Time in UTC that the query started executing, with 6 digits of precision for fractional seconds. For example: 2009-06-12 11:29:19.131358.
endtime timestamp Time in UTC that the query finished executing, with 6 digits of precision for fractional seconds. For example: 2009-06-12 11:29:19.131358.
sequence integer When a single statement contains more than 200 characters, additional rows are logged for that statement. Sequence 0 is the first row, 1 is the second, and so on.
text character(200) SQL text, in 200-character increments.

Sample Queries

The following query returns the text for "utility" commands that were run on January 26th, 2012. In this case, some SET commands and a SHOW ALL command were run:

Copy
select starttime, sequence, rtrim(text) from stl_utilitytext where starttime like '2012-01-26%' order by starttime, sequence; starttime | sequence | rtrim ---------------------------+-----+---------------------------------- 2012-01-26 13:05:52.529235 | 0 | show all; 2012-01-26 13:20:31.660255 | 0 | SET query_group to '' 2012-01-26 13:20:54.956131 | 0 | SET query_group to 'soldunsold.sql' ...