database 如何获取postgresql中表的总数?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13931494/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 08:49:16  来源:igfitidea点击:

How to get the total number of tables in postgresql?

databasepostgresqlpostgresql-8.4

提问by harry

Is there any way by which I can get the total number of tables in a Postgresql database? The postgresql version I'm using is PostgreSQL 8.4.14.

有什么方法可以获取 Postgresql 数据库中的表总数?我使用的 postgresql 版本是 PostgreSQL 8.4.14。

回答by a_horse_with_no_name

select count(*)
from information_schema.tables;

Or if you want to find the number of tables only for a specific schema:

或者,如果您只想查找特定模式的表数:

select count(*)
from information_schema.tables
where table_schema = 'public';

回答by sufleR

Just try to search in pg_stat... tables or information_schema you can find there very useful informations about your database.
Example:

只需尝试在 pg_stat... 表或 information_schema 中搜索,您就可以找到有关您的数据库的非常有用的信息。
例子:

select * from  pg_stat_user_tables ;
select count(*) from  pg_stat_user_tables ; 
select * from  pg_stat_all_tables ;

回答by pipaliya uttam

select Count(*) from sys.tables