自定义数据类型相关操作
最近更新时间: 2024-10-17 17:10:00
- 建立数据类型。
postgres=# CREATE TYPE bug_status AS ENUM('new', 'open', 'closed');
CREATE TYPE
- \dT查看自定义数据类型列表。
postgres=# \dT
List ofdata types
Schema | Name | Description
-----------+------------+--------------------------
pg_oracle | nvarchar2 | oracle nvarchar2(length)
pg_oracle | varchar2 | oracle varchar2(length)
public | bug_status |
- \dT+查看自定义数据类型列表详细信息(包含enum类型的值)。
postgres=# \dT+
List ofdata types
Schema | Name | Internal name | Size |Elements | Access privileges | Description
-----------+------------+---------------+-------+----------+-------------------+--------------------------
pg_oracle | nvarchar2 | nvarchar2 | var | | | oracle nvarchar2(length)
pg_oracle | varchar2 | varchar2 | var | | | oracle varchar2(length)
public | bug_status | bug_status | 4 | new +| |
| | | | open +| |
| | | | closed | |
- \dT+显示某个模式下的所有自定义类型。
postgres=# \dT+ public.*
List ofdata types
Schema | Name | Internal name | Size |Elements | Access privileges | Description
--------+------------+---------------+-------+----------+-------------------+-------------
public | bug_status | bug_status | 4 | new +| |
| | | | open +| |
| | | | closed | |
- \dT+自定义数据类型显示某个数据类型的详细信息。
postgres=# \dT+ bug_status
List ofdata types
Schema | Name | Internal name | Size |Elements | Access privileges | Description
--------+------------+---------------+------+----------+-------------------+-------------
public | bug_status | bug_status | 4 | new +| |
| | | | open +| |
| | | | closed | |
(1 row)
- \dT+通配符列出适配的数据类型。
postgres=# \dT+ bug_*
List ofdata types
Schema | Name | Internal name | Size |Elements | Owner | Access privileges | Description
--------+------------+---------------+------+----------+-------+-------------------+-------------
public | bug_status | bug_status | 4 | new +| tbase | |
| | | | open +| | |
| | | | closed | | |