如何使用psql命令在PostgreSQL中执行Oracle的DESCRIBE TABLE?


当前回答

当表名以大写字母开头时,应将表名放在引号中。

示例:\d“用户”

其他回答

尝试以下操作(在psql命令行工具中):

\d+ tablename

有关更多信息,请参阅手册。

Use this command 

\d table name

like 

\d queuerecords

             Table "public.queuerecords"
  Column   |            Type             | Modifiers
-----------+-----------------------------+-----------
 id        | uuid                        | not null
 endtime   | timestamp without time zone |
 payload   | text                        |
 queueid   | text                        |
 starttime | timestamp without time zone |
 status    | text                        |

除了PostgreSQL方式(\d“something”或\dt“table”或\ds“sequence”等)

SQL标准方式,如下所示:

select column_name, data_type, character_maximum_length, column_default, is_nullable
from INFORMATION_SCHEMA.COLUMNS where table_name = '<name of table>';

它受到许多db引擎的支持。

您可以使用星号执行\d*搜索模式*,以查找与您感兴趣的搜索模式匹配的表。

In postgres\d用于描述表结构。

例如\d schema_name.table_name

该命令将为您提供表的基本信息,如列、类型和修饰符。

如果您想了解更多有关表格使用的信息

\d+ schema_name.table_name

这将为您提供额外的信息,如存储、统计目标和描述