PostgreSql 系统表pg

xiaoxiao2021-02-28  102

pg_enum表包含显示每个枚举类型值和标签的记录。

名字类型引用描述oidoid 行标识符(隐藏属性; 必须明确选择)enumtypidoidpg_type.oid拥有这个枚举值的pg_type记录的OIDenumsortorderfloat4 这个枚举值在它的枚举类型中的排序位置enumlabelname 这个枚举值的文本标签

- 实例

postgres=# select * from pg_enum ; (No rows)

可以看到系统表此时还没有枚举类型,我们可以自己定义一个枚举类型。

postgres=# create type mood as enum('sad','ok','happy'); CREATE TYPE postgres= postgres=# select * from pg_enum ; enumtypid | enumsortorder | enumlabel -----------+---------------+----------- 65750 | 1 | sad 65750 | 2 | ok 65750 | 3 | happy (3 rows)

enumtypid是对应表pg_type的oid,因为它也是一中可以使用的数据类型。

postgres=# select * from pg_type where oid=65750 ; -[ RECORD 1 ]--+---------- typname | mood typnamespace | 2200 typowner | 10 typlen | 4 typbyval | t typtype | e typcategory | E typispreferred | f typisdefined | t typdelim | , typrelid | 0 typelem | 0 typarray | 65749 typinput | enum_in typoutput | enum_out typreceive | enum_recv typsend | enum_send typmodin | - typmodout | - typanalyze | - typalign | i typstorage | p typnotnull | f typbasetype | 0 typtypmod | -1 typndims | 0 typcollation | 0 typdefaultbin | typdefault | typacl |

typname是我们定义的mood。枚举类型的使用参考: PostgreSQL enum的使用

转载请注明原文地址: https://www.6miu.com/read-72290.html

最新回复(0)