品易云推流 关闭
文章详情页
文章 > PostgreSQL > postgresql查看数据库里有哪些表的方法

postgresql查看数据库里有哪些表的方法

头像

yang

2020-04-05 14:05:587896浏览 · 0收藏 · 0评论

1、使用\d命令查看postgresql中所有表

格式:

\d [ pattern ]

\d [ pattern ] +

该命令将显示每个匹配关系(表,视图,索引,序列)的信息,包括对象所有的列,它们的类型,表空间(如果不是默认的)和任何特殊属性(如NOT NULL或默认值等)。与唯一约束相关的索引,规则,约束,触发器也同样会显示出来。

如果\d命令什么都不带,将列出当前数据库中的所有表:

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中所有的表信息:

select * from pg_tables;

推荐:PostgreSQL教程

关注

关注公众号,随时随地在线学习

本教程部分素材来源于网络,版权问题联系站长!

底部广告图