Greenplum数据库中系统表pg_attribute详解

Greenplum数据库中系统表pg_attribute详解

该系统表存储所有表(包括系统表,如pg_class)的字段信息。数据库中的每个表的每个字段在pg_attribute表中都有一行记录。

 

 举例:

1,查看指定表中包含的字段名和字段编号。

SELECT relname, attname,attnum FROM pg_class c,pg_attribute attr WHERE relname  = 'tablename' AND c.oid = attr.attrelid;

2,只查看用户自定义字段的类型.

SELECT relname,attname,typname FROM pg_class c,pg_attribute a,pg_type t WHERE c.relname = 'testtable' AND c.oid = attrelid AND atttypid = t.oid AND attnum > 0;

猜你喜欢

转载自www.cnblogs.com/lizm166/p/12102389.html