8.15. DESCRIBE OUTPUT

Synopsis

  1. DESCRIBE OUTPUT statement_name

Description

List the output columns of a prepared statement, including thecolumn name (or alias), catalog, schema, table, type, type size inbytes, and a boolean indicating if the column is aliased.

Examples

Prepare and describe a query with four output columns:

  1. PREPARE my_select1 FROM
  2. SELECT * FROM nation
  1. DESCRIBE OUTPUT my_select1;
  1. Column Name | Catalog | Schema | Table | Type | Type Size | Aliased
  2. -------------+---------+--------+--------+---------+-----------+---------
  3. nationkey | tpch | sf1 | nation | bigint | 8 | false
  4. name | tpch | sf1 | nation | varchar | 0 | false
  5. regionkey | tpch | sf1 | nation | bigint | 8 | false
  6. comment | tpch | sf1 | nation | varchar | 0 | false
  7. (4 rows)

Prepare and describe a query whose output columns are expressions:

  1. PREPARE my_select2 FROM
  2. SELECT count(*) as my_count, 1+2 FROM nation
  1. DESCRIBE OUTPUT my_select2;
  1. Column Name | Catalog | Schema | Table | Type | Type Size | Aliased
  2. -------------+---------+--------+-------+--------+-----------+---------
  3. my_count | | | | bigint | 8 | true
  4. _col1 | | | | bigint | 8 | false
  5. (2 rows)

Prepare and describe a row count query:

  1. PREPARE my_create FROM
  2. CREATE TABLE foo AS SELECT * FROM nation
  1. DESCRIBE OUTPUT my_create;
  1. Column Name | Catalog | Schema | Table | Type | Type Size | Aliased
  2. -------------+---------+--------+-------+--------+-----------+---------
  3. rows | | | | bigint | 8 | false
  4. (1 row)

See Also

PREPARE