如何使用Postgres information_schema列出自定义类型 [英] How to list custom types using Postgres information_schema
问题描述
我正在尝试使用information_schema查找\dT的等效SQL,但似乎找不到任何内容。这样的事情存在吗?
I am trying to find the equivalent SQL of \dT using the information_schema and can't seem to find anything. Does such a thing exist?
示例:如果添加以下自定义类型枚举,如何在information_schema中看到它?
Example: If I add the following custom type enum, how can I see it in the information_schema?
CREATE TYPE communication.channels AS ENUM
('text_message',
'email',
'phone_call',
'broadcast');
注意:我确实拥有\dT使用的确切SQL(通过打开日志记录进行检索)但我专门在寻找一种使用information_schema
NOTE: I do have the exact SQL used by \dT (retrieved by turning up the logging) but I am looking specifically for a cleaner implementation using the information_schema
推荐答案
Enums不在SQL标准中,因此未在信息模式。其他用户定义类型通常会在 user_defined_types
视图中,但未实现。因此,目前您无法使用信息架构在PostgreSQL中列出用户定义的类型。
Enums are not in the SQL standard and therefore not represented in the information schema. Other user-defined types would normally be in the view user_defined_types
, but that's not implemented. So at the moment, you can't use the information schema to list user-defined types in PostgreSQL.
这篇关于如何使用Postgres information_schema列出自定义类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!