加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

postgresql列表和按大小排序的表

发布时间:2020-12-13 16:30:22 所属栏目:百科 来源:网络整理
导读:有没有一种简单的方法可以列出PostgreSQL数据库中的所有表并按大小排序? 伪代码 SELECT * FROM tablesORDER by tables.size 我正在使用PostgreSQL 9.3.2. select table_name,pg_relation_size(quote_ident(table_name))from information_schema.tableswhere
有没有一种简单的方法可以列出PostgreSQL数据库中的所有表并按大小排序?

伪代码

SELECT * FROM tables
ORDER by tables.size

我正在使用PostgreSQL 9.3.2.

select table_name,pg_relation_size(quote_ident(table_name))
from information_schema.tables
where table_schema = 'public'
order by 2

如果您有多个模式,则可以显示模式公共中所有表的大小,您可能希望使用:

select table_schema,table_name,pg_relation_size('"'||table_schema||'"."'||table_name||'"')
from information_schema.tables
order by 3

SQLFiddle示例:http://sqlfiddle.com/#!15/13157/3

手册中所有对象大小函数的列表:
https://www.postgresql.org/docs/current/static/functions-admin.html#FUNCTIONS-ADMIN-DBSIZE

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读