greenplum获取表schame信息

1,获取表 信息

select * from information_schema."tables" t  ;

2,获取字段详情

select * from information_schema.columns c where c.table_name ='表名';

3,获取表具体字段备注信息

SELECT UPPER(A.SCHEMANAME) AS SCHEMANAME,
       UPPER(A.TABLENAME) AS TABLENAME,
       --D.ATTRELID ,  
       --D.ATTRELID::regclass,
       UPPER(D.ATTNAME) AS ATTNAME,
       REPLACE(REPLACE(REPLACE(FORMAT_TYPE(D.ATTTYPID, D.ATTTYPMOD),
                               'numeric',
                               'NUMBER'),
                       'character varying',
                       'VARCHAR2'),
               'date',
               'DATE') AS DATA_TYPE,
       E.DESCRIPTION
  FROM PG_TABLES A
 INNER JOIN PG_CLASS B
    ON A.TABLENAME = B.RELNAME
  LEFT JOIN PG_CATALOG.PG_DESCRIPTION E
    ON B.OID = E.OBJOID
  LEFT JOIN PG_CATALOG.PG_ATTRIBUTE D
    ON D.ATTRELID = E.OBJOID
   AND D.ATTNUM = E.OBJSUBID
 WHERE SCHEMANAME = '表空间'
   AND A.TABLENAME LIKE '%表名称%'
   AND D.ATTNUM > 0
  ORDER BY A.TABLENAME ,D.ATTNUM

posted @ 2021-12-28 14:19  iullor  阅读(287)  评论(0编辑  收藏  举报