Compare commits
3 Commits
master
...
424b9882bb
| Author | SHA1 | Date | |
|---|---|---|---|
| 424b9882bb | |||
| c46757f76f | |||
| 15b1c485d2 |
@@ -1,5 +1,7 @@
|
|||||||
-- search_path
|
-- 修改用户的密码
|
||||||
SHOW search_path;
|
alter user postgres with password '123456';
|
||||||
|
-- 查询所有用户
|
||||||
|
select * from pg_catalog.pg_user;
|
||||||
|
|
||||||
-- 查询表的 COLLATION VERSION
|
-- 查询表的 COLLATION VERSION
|
||||||
SELECT
|
SELECT
|
||||||
@@ -32,26 +34,6 @@ select r.ctid, r.* from study.r;
|
|||||||
|
|
||||||
-- 删除一条
|
-- 删除一条
|
||||||
delete from study.r where id = 2;
|
delete from study.r where id = 2;
|
||||||
-- 再重新查询,得到
|
-- 在重新查询,得到
|
||||||
-- "(0,1)",1,101
|
-- "(0,1)",1,101
|
||||||
-- "(0,3)",3,103
|
-- "(0,3)",3,103
|
||||||
-- PostgreSQL 会保留空槽
|
|
||||||
|
|
||||||
-- 插入新数据
|
|
||||||
insert into study.r values (104, 4);
|
|
||||||
-- 再重新查询,得到
|
|
||||||
-- "(0,1)",1,101
|
|
||||||
-- "(0,3)",3,103
|
|
||||||
-- "(0,4)",4,104
|
|
||||||
-- 可以看到使用了末尾的新槽位,而不是使用中间的新槽位
|
|
||||||
|
|
||||||
-- 执行清理
|
|
||||||
vacuum full study.r;
|
|
||||||
-- 再次扫面,得到
|
|
||||||
-- "(0,1)",1,101
|
|
||||||
-- "(0,2)",3,103
|
|
||||||
-- "(0,3)",4,104
|
|
||||||
-- 看到空间已经回收
|
|
||||||
|
|
||||||
-- 查看数据类型
|
|
||||||
select pg_typeof(EXTRACT(EPOCH FROM current_timestamp(0)))
|
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
-- 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
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
-- 不阻塞的情况下创建索引
|
|
||||||
create index concurrently idx_prism_timestamp on activities (timestamp);
|
|
||||||
@@ -8,6 +8,3 @@ 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;
|
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
-- 修改用户的密码
|
|
||||||
alter user postgres with password '123456';
|
|
||||||
-- 查询所有用户
|
|
||||||
select * from pg_catalog.pg_user;
|
|
||||||
Reference in New Issue
Block a user