CREATETABLE"kingbase"."test_szie"("id"integerAUTO_INCREMENT,"name"charactervarying(8char)NOTNULL,"create_time"timestamp without time zone NOTNULL,"update_time"timestamp without time zone NOTNULL,"in_number"integerNULL,"number"integerNULL,CONSTRAINT"con_kingbase_test_szie_id"PRIMARYKEY(id));ALTERTABLE"kingbase".test_szie SETTABLESPACE"sys_default";INSERTINTO"kingbase"."test_szie"("number","name","create_time","update_time","in_number")VALUES(generate_series(1,99999),'张三',now(),now(), random());CREATETABLE"kingbase"."test_szie1"("id"integerAUTO_INCREMENT,"name"charactervarying(8char)NOTNULL,"create_time"timestamp without time zone NOTNULL,"update_time"timestamp without time zone NOTNULL,"in_number"integerNULL,"number"integerNULL,CONSTRAINT"con_kingbase_test_szie_id"PRIMARYKEY(id));ALTERTABLE"kingbase".test_szie1 SETTABLESPACE"sys_default";ALTERTABLE"kingbase".test_szie1 SETTABLESPACE"sys_default";INSERTINTO"kingbase"."test_szie1"("number","name","create_time","update_time","in_number")VALUES(generate_series(1,99999),'张三',now(),now(), random());
select sys_database.datname, sys_database_size(sys_database.datname)as size from sys_database orderby size desc;
查询kingbase模式大小
SELECT
sys_size_pretty(sum(table_size)::bigint)as"disk space",sum(table_size)::bigintas"total size"FROM(SELECT sys_catalog.sys_namespace.nspname as schema_name,
sys_total_relation_size(sys_catalog.sys_class.oid)as table_size
FROM sys_catalog.sys_class
JOIN sys_catalog.sys_namespace
ON relnamespace = sys_catalog.sys_namespace.oid
WHERE sys_catalog.sys_namespace.nspname ='kingbase') t
查询库下所有模式大小
SELECT schema_name,
sys_size_pretty(sum(table_size)::bigint)as"disk space",sum(table_size)::bigintas"total size"FROM(SELECT sys_catalog.sys_namespace.nspname as schema_name,
sys_total_relation_size(sys_catalog.sys_class.oid)as table_size
FROM sys_catalog.sys_class
JOIN sys_catalog.sys_namespace
ON relnamespace = sys_catalog.sys_namespace.oid
WHERE sys_catalog.sys_namespace.nspname NOTIN('information_schema','src_restrict','anon','dbms_sql','xlog_record_read','pg_catalog','pg_bitmapindex','sys_catalog','sysaudit','sysmac','sys')) t
GROUPBY schema_name