In Panoply, you can retrieve the past queries you have executed by running a query against the
STL_QUERY system table. This table returns execution information about the database queries you've run in the past. It's also one of the many system tables you can query in Panoply.
Below is a sample query that lists the five most recent queries. Use the Panoply Workbench tool or any SQL client tool to execute it.
SELECT query, label, database, trim(querytxt) AS sqlquery FROM stl_query ORDER BY starttime DESC LIMIT 5;
Some notes to keep in mind when querying the
- The table only contains information about queries and does not log DDL-related commands (
DROP TABLE, etc.). Check the
STL_DDLTEXTsystem table regarding recorded DDL statements.
- The table retains approximately two to five days of log history, depending on log usage and available disk space.
- The table also includes information about the current database where you executed the query with and currently connected user.