简单方便的获取所有表的条数

文章目录

文档用途

我们知道oracle里有一个系统表存的rownum。本文旨在介绍在HG数据库中简单方便的获取所有表的条数的方法。

详细信息

通过如下sql:

sql 复制代码
select relname as 表名, reltuples as 条数 from pg_class where relkind = 'r' and relnamespace = (select oid from pg_namespace where nspname='highgo') order by 条数 desc;

效果如下:

sql 复制代码
highgo=# select relname as 表名, reltuples as 条数 from pg_class where relkind = 'r' and relnamespace = (select oid from pg_namespace where nspname='highgo') order by 条数 desc;



   表名    | 条数 

-------------+--------

 t1          |      0

 aaa         |      0

 b           |      0

 test1       |      0

 t           |      0

 d1          |      0

 d2          |      0

 product     |      0

 addressbook |      5

(9 rows)

在很多情况下这个值是一个参考值,想更新此值可以通过如下命令:

sql 复制代码
highgo=# select * from t1;

 a | b 

---+---

 3 | a

(1 row)



highgo=# analyze t1;

ANALYZE

效果如下:

sql 复制代码
highgo=# select relname as 表名, reltuples as 条数 from pg_class where relkind = 'r' and relnamespace = (select oid from pg_namespace where nspname='highgo') order by 条数 desc;



   表名    | 条数 

-------------+--------

 t1          |      1

 aaa         |      0

 b           |      0

 test1       |      0

 t           |      0

 d1          |      0

 d2          |      0

 product     |      0

 addressbook |      5

(9 rows)
相关推荐
瀚高PG实验室8 天前
xx000 can not wait without a pgproc
服务器·数据库·oracle·瀚高数据库
瀚高PG实验室10 天前
PG的JDBC对SQL中绑定变量个数的限制
数据库·sql·postgresql·瀚高数据库
瀚高PG实验室10 天前
瀚高数据库V45及V6用户锁定后解锁步骤
运维·数据库·瀚高数据库
瀚高PG实验室12 天前
left link changed unexpectedly in block xxxx of index ““index_xxxxx“
数据库·postgresql·瀚高数据库
瀚高PG实验室12 天前
debezium在LANG=zh_CN.UTF-8下,无法解析timestamp类型的列值为BC的字段
服务器·数据库·postgresql·瀚高数据库
瀚高PG实验室13 天前
postgresql因在从库备份时间长而失败
运维·数据库·postgresql·瀚高数据库
瀚高PG实验室22 天前
安全版V4.5版本docker容器license过期问题处理步骤
安全·docker·容器·瀚高数据库
瀚高PG实验室22 天前
ERROR: invalid input syntax for type integer: “a“
数据库·瀚高数据库