在PostgreSQL的information_schema中列出所有表的最好方法是什么?

澄清一下:我正在使用一个空DB(我没有添加任何自己的表),但我想查看information_schema结构中的每个表。


当前回答

列出你的表使用:

SELECT table_name FROM information_schema.tables WHERE table_schema='public'

它将只列出您创建的表。

其他回答

select * from information_schema.tables where table_schema = 'public' and table_type = 'BASE TABLE'

只订你们的桌子

您应该能够从information_schema中运行select *。获得Postgres为特定数据库管理的每个表的列表。

您还可以添加where table_schema = 'information_schema'来查看信息模式中的表。

\dt information_schema.

从psql内部,应该没问题。

列出你的表使用:

SELECT table_name FROM information_schema.tables WHERE table_schema='public'

它将只列出您创建的表。

你可以用also

select * from pg_tables where schemaname = 'information_schema'

一般来说,pg* tables允许您查看db中的所有内容,不受您的权限限制(当然,如果您有权限访问这些表)。