1
0

Compare commits

...

3 Commits

Author SHA1 Message Date
13e48717eb 索引 2025-12-02 19:16:41 +08:00
5dec90aa2a update 2025-12-02 19:16:31 +08:00
7a5099188e update 2025-11-19 05:51:56 +08:00
5 changed files with 20 additions and 4 deletions

View File

@@ -1,7 +1,5 @@
-- 修改用户的密码 -- search_path
alter user postgres with password '123456'; SHOW search_path;
-- 查询所有用户
select * from pg_catalog.pg_user;
-- 查询表的 COLLATION VERSION -- 查询表的 COLLATION VERSION
SELECT SELECT
@@ -54,3 +52,6 @@ vacuum full study.r;
-- "(0,2)",3,103 -- "(0,2)",3,103
-- "(0,3)",4,104 -- "(0,3)",4,104
-- 看到空间已经回收 -- 看到空间已经回收
-- 查看数据类型
select pg_typeof(EXTRACT(EPOCH FROM current_timestamp(0)))

6
PostgreSQL/function.sql Normal file
View File

@@ -0,0 +1,6 @@
-- ROW 关键字生成一个元组
SELECT ROW (1, 2, 3);
-- pg_column_size函数获取存储数据需要的字节数
SELECT pg_column_size(ROW (1,2,3)); -- 36
SELECT pg_column_size(ROW (1::int2, 2::int2, 3::int2)); -- 30

2
PostgreSQL/index.sql Normal file
View File

@@ -0,0 +1,2 @@
-- 不阻塞的情况下创建索引
create index concurrently idx_prism_timestamp on activities (timestamp);

View File

@@ -8,3 +8,6 @@ select msg_time at time zone 'Asia/Shanghai' from msg where id = 1;
select msg_time at time zone 'UTC+8' from msg where id = 1; select msg_time at time zone 'UTC+8' from msg where id = 1;
select to_timestamp(1761850339) AT TIME ZONE 'Asia/Shanghai'; select to_timestamp(1761850339) AT TIME ZONE 'Asia/Shanghai';
-- 将当前时间转换为Unix时间戳
select EXTRACT(EPOCH FROM current_timestamp(0)) - 60;

4
PostgreSQL/user.sql Normal file
View File

@@ -0,0 +1,4 @@
-- 修改用户的密码
alter user postgres with password '123456';
-- 查询所有用户
select * from pg_catalog.pg_user;