1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
SELECT C
.relname 表名,
CAST ( obj_description ( relfilenode, 'pg_class' ) AS VARCHAR ) 名称,
A.attname 字段,
concat_ws (
'',
T.typname,
SUBSTRING ( format_type ( A.atttypid, A.atttypmod ) FROM '\(.*\)' )) AS 列类型,
d.description 字段备注
FROM
pg_class C,
pg_attribute A,
pg_type T,
pg_description d
WHERE
A.attnum > 0
AND A.attrelid = C.oid
AND A.atttypid = T.oid
AND d.objoid = A.attrelid
AND d.objsubid = A.attnum
AND C.relname IN ( SELECT tablename FROM pg_tables WHERE schemaname = 'public' AND POSITION ( '_2' IN tablename ) = 0 )
ORDER BY
C.relname,
A.attnum
|