Categories:
Account & Session DDL

DESCRIBE RESULT

Describes the columns in the result of a query you executed (within 24 hours of when you executed the query).

The query can be from the current session or any of your other sessions, including past sessions, as long as the 24 hour period has not elapsed. This period is not adjustable. For more details, see Using Persisted Query Results.

DESCRIBE can be abbreviated to DESC.

See also:
LAST_QUERY_ID (Context function) , RESULT_SCAN (Table function)

Syntax

DESC[RIBE] RESULT { '<query_id>' | LAST_QUERY_ID() }

Parameters

query_id or LAST_QUERY_ID()
Specifies either the ID for a query you executed (within the last 24 hours in any session) or the LAST_QUERY_ID function, which returns the ID for a query within your current session.

Usage Notes

  • To retrieve the ID for a specific query:

    • Locate the query ID in the web interface. The History History tab page lists the ID along with each query; however, note that you can only use this function for queries you have executed.

    • Execute the QUERY_HISTORY , QUERY_HISTORY_BY_* table function, which returns a list of queries and their IDs; however, note that you can only use this function for queries you have executed.

    • If the query was executed in the current session, execute the LAST_QUERY_ID function. For example:

      SELECT LAST_QUERY_ID(-2);
      

      Note that this is equivalent to using LAST_QUERY_ID() as the input for DESC RESULT.

  • To post-process the output of this command, you can use the RESULT_SCAN function, which treats the output as a table that can be queried.

Examples

Describe the columns in the result of the specified query from any of your sessions (within the previous 24 hours):

DESC RESULT 'f2f07bdb-6a08-4689-9ad8-a1ba968a44b6';

Describe the columns in the results from your most recent query in the current session:

SELECT * FROM boston_sales;

+---------------+-------+-------+--------+-------------+---------------------+-------+
| CITY          | ZIP   | STATE | SQ__FT | TYPE        | SALE_DATE           | PRICE |
|---------------+-------+-------+--------+-------------+---------------------+-------|
| MA-Lexington  | 40502 | MA    |    836 | Residential | 0016-01-25T00:00:00 | 59222 |
| MA-Belmont    | 02478 | MA    |    852 | Residential | 0016-02-21T00:00:00 | 69307 |
| MA-Winchester | 01890 | MA    |   1122 | Condo       | 0016-01-31T00:00:00 | 89921 |
+---------------+-------+-------+--------+-------------+---------------------+-------+

DESC RESULT LAST_QUERY_ID();

+-----------+-------------------+--------+-------+---------+-------------+------------+-------+------------+---------+
| name      | type              | kind   | null? | default | primary key | unique key | check | expression | comment |
|-----------+-------------------+--------+-------+---------+-------------+------------+-------+------------+---------|
| CITY      | VARCHAR(16777216) | COLUMN | Y     | NULL    | N           | N          | NULL  | NULL       | NULL    |
| ZIP       | VARCHAR(16777216) | COLUMN | Y     | NULL    | N           | N          | NULL  | NULL       | NULL    |
| STATE     | VARCHAR(16777216) | COLUMN | Y     | NULL    | N           | N          | NULL  | NULL       | NULL    |
| SQ__FT    | NUMBER(38,0)      | COLUMN | Y     | NULL    | N           | N          | NULL  | NULL       | NULL    |
| TYPE      | VARCHAR(16777216) | COLUMN | Y     | NULL    | N           | N          | NULL  | NULL       | NULL    |
| SALE_DATE | DATE              | COLUMN | Y     | NULL    | N           | N          | NULL  | NULL       | NULL    |
| PRICE     | NUMBER(38,0)      | COLUMN | Y     | NULL    | N           | N          | NULL  | NULL       | NULL    |
+-----------+-------------------+--------+-------+---------+-------------+------------+-------+------------+---------+