参考ページ
テーブルの数を数える
SELECT count(*) FROM information_schema.tables WHERE table_schema NOT IN ('pg_catalog', 'information_schema');
実行例
db_common=# SELECT count(*) FROM information_schema.tables WHERE table_schema NOT IN ('pg_catalog', 'information_schema');
count
-------
1583
(1 row)
テーブル名が g で始まるものの数を数える
SELECT count(*) FROM information_schema.tables WHERE table_schema NOT IN ('pg_catalog', 'information_schema') and table_name like 'g%';
実行例
db_common=# SELECT count(*) FROM information_schema.tables WHERE table_schema NOT IN ('pg_catalog', 'information_schema') and table_name like 'g%';
count
-------
1241
(1 row)
テーブルの一覧
all01.sql
SELECT table_name FROM information_schema.tables WHERE table_schema NOT IN ('pg_catalog', 'information_schema') order by table_name;
実行例
psql -Uscott db_common < all01.sql > all01.txt
テーブル名が g で始まるものの一覧
g01.sql
SELECT table_name FROM information_schema.tables WHERE table_schema NOT IN ('pg_catalog', 'information_schema') and table_name like 'g%' order by table_name;
実行例
psql -Uscott db_common < g01.sql > g01.txt