如何在一种特定模式中列出所有postgres表


10

使用psql命令行工具,如何在一个特定模式中列出所有postgres表

Answers:



2

除了\dt匹配项,您还可以查看数据库目录:

SELECT nspname||'.'||relname AS full_rel_name
  FROM pg_class, pg_namespace
 WHERE relnamespace = pg_namespace.oid
   AND nspname = 'yourschemaname'
   AND relkind = 'r';

您也可以使用更标准的信息模式来执行此操作,但是它通常会比较慢:

SELECT table_schema||'.'||table_name AS full_rel_name
  FROM information_schema.tables
 WHERE table_schema = 'yourschemaname';

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.