「PostgreSQL」テーブル一覧を取得する方法
環境
Windows 10 Home 64bit
PostgreSQL 9.6.5
使用例
テーブル一覧をテーブル名順に取得します
方法1
SQL構文
select
tablename
from
pg_tables
where
schemaname not in ('pg_catalog', 'information_schema')
order by
tablename;
実行結果
tablename ----------- address infotbl kdftbl ktbl
方法2
「\dt」コマンドで単にテーブルの一覧を取得します
書式
\dt
使用例
postgres=# \dt
リレーションの一覧
スキーマ | 名前 | 型 | 所有者
----------+---------+----------+----------
public | address | テーブル | postgres
public | empp | テーブル | postgres
public | ktbl | テーブル | postgres
(3 行)