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

文章目录

文档用途

我们知道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实验室6 分钟前
arcGis连不上HighGoDB的解决方案
arcgis·瀚高数据库
瀚高PG实验室2 天前
pg_relation_size,pg_table_size,pg_indexes_size,pg_total_relation_size之间的关系
postgresql·瀚高数据库
瀚高PG实验室6 天前
search_path的作用与用法
瀚高数据库
瀚高PG实验室8 天前
使用安全版数据库开启ssl加密后jdbc写法
数据库·安全·ssl·瀚高数据库
瀚高PG实验室9 天前
pgsql_tmp文件夹体积快速增加
数据库·瀚高数据库
瀚高PG实验室13 天前
逻辑导入导出(pg_dump/pg_restore)用法2-导入到不同的schema或tablespace
数据库·瀚高数据库
瀚高PG实验室18 天前
无法连接到服务器:连接被拒绝
运维·服务器·瀚高数据库
瀚高PG实验室23 天前
highgo DB中数据库对象,模式,用户,权限之间的关系
数据库·瀚高数据库
瀚高PG实验室23 天前
HIGHGODB内部MVCC机制简介
瀚高数据库