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

文章目录

文档用途

我们知道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 天前
数据库启动报错:42501: 无法打开共享内存段 “/PostgreSQL.******“: 权限不够
数据库·postgresql·瀚高数据库
瀚高PG实验室2 天前
流复制备库停机维护前检查步骤
数据库·瀚高数据库·highgo
瀚高PG实验室6 天前
pgsql-ogr-fdw
数据库·postgresql·瀚高数据库·highgo
瀚高PG实验室7 天前
python连接HGDB超时
数据库·瀚高数据库·highgo
瀚高PG实验室14 天前
V4.5.6.1授予普通用户监控类系统表及视图的查询权限
数据库·瀚高数据库
瀚高PG实验室18 天前
开发管理工具打不开No way to find ori gi nal streamhand er for jar protocol
java·数据库·jar·瀚高数据库
瀚高PG实验室18 天前
HGDB安全版单机修改用户密码
数据库·安全·瀚高数据库
瀚高PG实验室21 天前
瀚高企业版V9.1.1在pg_restore还原备份文件时提示extract函数语法问题
数据库·瀚高数据库