假设我们定义了一个postgresql类型:

CREATE TYPE my_type AS ENUM('foo', 'bar');

有没有办法在创建后显示类型定义?

我希望"\d my_type"会显示"ENUM('foo','bar'),但它说:

Did not find any relation named "my_type"

pg_类型表似乎没有提供足够的信息.

推荐答案

它是\dT您想要的,但它不会作为"CREATE"语句给出.您将\dD用于域.

\dT+ action.action_status
                          List of data types
 Schema |         Name         | Internal name | Size | Elements | Description 
--------+----------------------+---------------+------+----------+-------------
 action | action.action_status | action_status | 4    | pending +| 
        |                      |               |      | live    +| 
        |                      |               |      | done    +| 
        |                      |               |      | notdone  | 
(1 row)

Postgresql相关问答推荐

如何使用postgr sql regex删除重复项和inc表记录

端口5432失败:致命:数据库xxx&不存在.在PostgreSQL数据库中

将具有自定义类型的表从一种模式复制到另一种模式

PostgreSQL:在 select 和 group by 中使用不同的列不会导致错误

将数组的所有元素循环到jsonb中并修改值

Postgresql如何从jsonB列的数组中的多个json中 Select 一个值

sql:转换参数 $1 类型:不支持的类型 []int,in 的一部分

获取 OperationalError: FATAL: sorry, too many clients already using psycopg2

Windows PSQL 命令行: is there a way to allow for passwordless login?

Postgres 图像未创建数据库

Flask-SQLAlchemy db.session.query(Model) 与 Model.query

如何使 Java 和 Postgres 枚举一起工作以进行更新?

Postgres 外键on update和on delete选项如何工作?

Postgres 类似于 SQL Server 中的 CROSS APPLY

当成功有时会导致退出代码为 1 时,如何可靠地确定 pg_restore 是否成功?

如何增加 max_locks_per_transaction

使用 Postgres 在 Rust 的 Diesel 库中添加时间戳

我应该在 Django DATABASE ENGINE 中使用哪个 Postgres 值?

pg_restore 目录错误

postgresql NOT ILIKE 子句不包含空字符串值