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

3,923次阅读
没有评论

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

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教程

神龙|纯净稳定代理IP免费测试>>>>>>>>天启|企业级代理IP免费测试>>>>>>>>IPIPGO|全球住宅代理IP免费测试
2

相关文章:

版权声明:postgresql2022-12-02发表,共计650字。
新手QQ群:570568346,欢迎进群讨论 Python51学习