DESCRIBE OUTPUT

概要

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