小编eri*_*eri的帖子

解析 COPY 的二进制格式以访问 tsrange

tsrange 如何以二进制形式存储?

例如创建表

CREATE TABLE public.test (t tsrange);
INSERT INTO test VALUES ('[2010-01-01 14:30, 2010-01-01 15:30)');
INSERT INTO test VALUES ('[2011-01-01 14:31, 2015-11-01 15:30)');
INSERT INTO test VALUES ('[2017-01-01 14:31, 2018-11-01 15:30)');
COPY test TO '/tmp/pgcopy' WITH (FORMAT binary);
COPY test TO '/tmp/pgcopy.csv' WITH (FORMAT csv);
Run Code Online (Sandbox Code Playgroud)

它输出:

 cat /tmp/pgcopy.csv                                                                                                                                                                                                  
"[""2010-01-01 14:30:00"",""2010-01-01 15:30:00"")"
"[""2011-01-01 14:31:00"",""2015-11-01 15:30:00"")"
"[""2017-01-01 14:31:00"",""2018-11-01 15:30:00"")"


hexdump -C /tmp/pgcopy
00000000  50 47 43 4f 50 59 0a ff  0d 0a 00 00 00 00 00 00  |PGCOPY..........|
00000010 …
Run Code Online (Sandbox Code Playgroud)

postgresql dump date-format fields copy

4
推荐指数
1
解决办法
3791
查看次数

标签 统计

copy ×1

date-format ×1

dump ×1

fields ×1

postgresql ×1