1、获取uuid的2中方法
扩展插件
CREATE EXTENSION pgcrypto;
查看扩展函数
select * from pg_extension;
查看可安装的扩展函数
select * from pg_available_extensions;
生成id
SELECT gen_random_uuid()
去掉-
select replace(gen_random_uuid()::text, '-', '');
扩展插件
create extension "uuid-ossp";
v1和v4都可以,v4的效率会慢一点
select uuid_generate_v1()
select uuid_generate_v4();
select replace(uuid_generate_v4()::text, '-', '');
2、sql的使用
- 查所有数据库大小 :select datname, pg_size_pretty (pg_database_size(datname)) AS size from pg_database;
- 查某个
- 查所有表大小 :select relname, pg_size_pretty(pg_total_relation_size(relid)) as size from pg_stat_user_tables;
- 查某个表大小 :select pg_size_pretty(pg_relation_size('表名'));