Hologres

2024-06-04#Hologres#阿里云

Hologres 与 PostgreSQL 有很多类似的地方。

获取数据库中的所有视图 🔗

SELECT
    *
FROM
    INFORMATION_SCHEMA.views
WHERE
    table_schema NOT IN ('pg_catalog', 'information_schema', 'pg_catalog')

结果:

table_catalogtable_schematable_nameview_definitioncheck_optionis_updatableis_insertable_intois_trigger_updatableis_trigger_deletableis_trigger_insertable_into
..............................

获取每个表的大小 🔗

参考《查看表和DB的存储大小 》

SELECT
    table_schema || '.' || table_name AS table_full_name,
    table_schema,
    table_name,
    pg_size_pretty(pg_relation_size(quote_ident(table_schema) || '.' || quote_ident(table_name))) AS table_size,
    pg_relation_size(quote_ident(table_schema) || '.' || quote_ident(table_name)) AS order_size
FROM
    information_schema.tables
WHERE
    table_schema NOT IN ('pg_catalog', 'information_schema', 'hologres')
ORDER BY
    order_size DESC;

加载中...