
1、使用\d命令查看postgresql中所有表
格式:
\d [ pattern ]
\d [ pattern ] +
该命令将显示每个匹配关系(表,视图,索引,序列)的信息,包括对象所有的列,它们的类型,表空间(如果不是默认的)和任何特殊属性(如NOT NULL或默认值等)。与唯一约束相关的索引,规则,约束,触发器也同样会显示出来。
如果\d命令什么都不带,将列出当前数据库中的所有表:
1 2 3 4 5 6 7 8 9 10 11 12 | sample_db=# \d
List of relations
Schema | Name | Type | Owner
--------+----------------+-------+---------
public | account | table | postgre
public | book | table | postgre
public | customers | table | postgre
public | fruits | table | postgre
...
public | view_t | view | postgre
public | view_t2 | view | postgre
(42 rows)
|
2、使用select命令查看数据库中的表
获取当前db中所有的表信息:
推荐:PostgreSQL教程