47

Postgresql データベース内のテーブルの総数を取得する方法はありますか? 私が使用している postgresql のバージョンは PostgreSQL 8.4.14 です。

4

4 に答える 4

71
select count(*)
from information_schema.tables;

または、特定のスキーマのみのテーブル数を見つけたい場合は、次のようにします。

select count(*)
from information_schema.tables
where table_schema = 'public';
于 2012-12-18T12:41:01.667 に答える
20

pg_stat... テーブルまたは information_schema を検索してみてください。データベースに関する非常に役立つ情報が見つかります。
例:

select * from  pg_stat_user_tables ;
select count(*) from  pg_stat_user_tables ; 
select * from  pg_stat_all_tables ;
于 2012-12-18T11:59:42.353 に答える
-5
select Count(*) from sys.tables
于 2016-10-21T10:12:48.670 に答える