数据仓库服务 GAUSSDB(DWS)-注释信息函数:col_description(table_oid, column_number)

时间:2024-04-18 16:25:16

col_description(table_oid, column_number)

描述:获取一个表字段的注释。

返回类型:text

备注:col_description返回一个表中字段的注释,通过表OID和字段号来声明。

示例:查询pg_class系统表获取表OID,查询INFORMATION_SCHEMA.COLUMNS系统视图获取column_number。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
SELECT COLUMN_NAME,ORDINAL_POSITION FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't' AND COLUMN_NAME = 'a';
column_name | ordinal_position
-------------+------------------
a           |                1
(1 row)

SELECT oid FROM pg_class WHERE relname='t';
  oid
-------
 44020
(1 row)

SELECT col_description(44020,1);
    col_description
-----------------------
 This is a test table.
(1 row)
support.huaweicloud.com/sqlreference-820-dws/dws_06_0343.html