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

文章目录

文档用途

我们知道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实验室2 天前
瀚高数据库运行日志(错误日志)查看与分析方法
数据库·postgresql·瀚高数据库
瀚高PG实验室2 天前
HGHAC集群版本升级
数据库·postgresql·瀚高数据库
瀚高PG实验室2 天前
发布端逻辑复制槽消失
数据库·postgresql·瀚高数据库
瀚高PG实验室5 天前
瀚高数据库创建新数据库卡住问题排查
数据库·postgresql·瀚高数据库
瀚高PG实验室5 天前
HGDB V9.0.5 .pgpass 免密登录提示 IsEncryptNon-base64 encoding 警告处理
数据库·postgresql·瀚高数据库
瀚高PG实验室6 天前
瀚高数据库提交数据后,是否需要COMMIT
数据库·postgresql·瀚高数据库
瀚高PG实验室11 天前
数据库使用psql及jdbc进行远程连接,不定时自动断开的解决办法
数据库·postgresql·瀚高数据库
瀚高PG实验室18 天前
瀚高数据库常用系统表查询入门指南(附常用SQL)
数据库·sql·postgresql·瀚高数据库
瀚高PG实验室22 天前
瀚高数据库序列介绍、使用及值不连续、重复写入等现象处理
数据库·postgresql·瀚高数据库