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

SVL_STATEMENTTEXT

Use the SVL_STATEMENTTEXT view to get a complete record of all of the SQL commands that have been run on the system.

The SVL_STATEMENTTEXT view contains the union of all of the rows in the STL_DDLTEXT, STL_QUERYTEXT, and STL_UTILITYTEXT tables. This view also includes a join to the STL_QUERY table.

SVL_STATEMENTTEXT 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 user who generated entry.
xid bigint Transaction ID associated with the statement.
pid integer Process ID for the 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 Exact time when the statement started executing, with 6 digits of precision for fractional seconds. For example: 2009-06-12 11:29:19.131358
endtime timestamp Exact time when the statement finished executing, with 6 digits of precision for fractional seconds. For example: 2009-06-12 11:29:19.193640
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.
type varchar(10) Type of SQL statement: QUERY, DDL, or UTILITY.
text character(200) SQL text, in 200-character increments.

Sample Query

The following query returns DDL statements that were run on June 16th, 2009:

Copy
select starttime, type, rtrim(text) from svl_statementtext where starttime like '2009-06-16%' and type='DDL' order by starttime asc; starttime | type | rtrim ---------------------------|------|-------------------------------- 2009-06-16 10:36:50.625097 | DDL | create table ddltest(c1 int); 2009-06-16 15:02:16.006341 | DDL | drop view alltickitjoin; 2009-06-16 15:02:23.65285 | DDL | drop table sales; 2009-06-16 15:02:24.548928 | DDL | drop table listing; 2009-06-16 15:02:25.536655 | DDL | drop table event; ...