DESCRIBE 输出

概要

DESCRIBE OUTPUT statement_name

描述

列出准备好的语句的输出列,包括列名(或别名)、目录、模式、表、类型、以字节为单位的类型大小以及一个布尔值,指示该列是否已别名。

示例

准备和描述一个具有四个输出列的查询

PREPARE my_select1 FROM
SELECT * FROM nation
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)

准备和描述一个输出列为表达式的查询

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

准备和描述一个行计数查询

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

另请参阅

PREPARE