Overview

DESCRIBE OUTPUT statement_name

Description

Lists all the column information about output results, including the column name (or alias), catalog, schema, table name, type, type size in bytes, and a boolean that indicates whether the column is aliased.

Examples

Example 1

Create a precompiled query statement:

PREPARE my_select1 FROM
SELECT * FROM nation;

Execute DESCRIBE OUTPUT, which returns the following output:

DESCRIBE OUTPUT my_select1;

 Column Name | Catalog | Schema | Table  |  Type   | Type Size | Aliased
-------------+---------+--------+--------+---------+-----------+---------
 nationkey   | tpch    | sf1    | nation | bigint  |         8 | false
 name        | tpch    | sf1    | nation | varchar |         0 | false
 regionkey   | tpch    | sf1    | nation | bigint  |         8 | false
 comment     | tpch    | sf1    | nation | varchar |         0 | false
(4 rows)

Example 2

PREPARE my_select2 FROM
SELECT count(*) as my_count, 1+2 FROM nation

Execute DESCRIBE OUTPUT, which returns the following output:

DESCRIBE OUTPUT my_select2;

 Column Name | Catalog | Schema | Table |  Type  | Type Size | Aliased 
-------------+---------+--------+-------+--------+-----------+---------
 my_count    |         |        |       | bigint |         8 | true
 _col1       |         |        |       | bigint |         8 | false
(2 rows)

Example 3

PREPARE my_create FROM
CREATE TABLE foo AS SELECT * FROM nation;

Execute DESCRIBE OUTPUT, which returns the following output:

DESCRIBE OUTPUT my_create;

 Column Name | Catalog | Schema | Table |  Type  | Type Size | Aliased
-------------+---------+--------+-------+--------+-----------+---------
 rows        |         |        |       | bigint |         8 | false 
(1 row)