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

文章目录

文档用途

我们知道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 天前
瀚高数据库使用IPv6连接的配置方法
数据库·瀚高数据库
瀚高PG实验室7 天前
表空间迁移
数据库·瀚高数据库
瀚高PG实验室9 天前
瀚高安全版 V4.5.10卸载后残留了db_ha的agent进程导致6666端口被占用
linux·数据库·安全·瀚高数据库
瀚高PG实验室1 个月前
数据库意外中止,无法启动
数据库·瀚高数据库
瀚高PG实验室1 个月前
hghac8008漏洞扫描处理
linux·网络·windows·瀚高数据库
瀚高PG实验室1 个月前
如何查看数据库以及内核版本
数据库·瀚高数据库
瀚高PG实验室1 个月前
HighGo Database中的约束条件
数据库·瀚高数据库
瀚高PG实验室2 个月前
数据库日志过大
数据库·瀚高数据库
瀚高PG实验室2 个月前
PostgreSQL到HighgoDB数据迁移
数据库·postgresql·瀚高数据库
瀚高PG实验室2 个月前
通过数据库日志获取数据库中的慢SQL
数据库·sql·瀚高数据库