使用PostgreSQL copy命令binary格式从高版本导出低版本导入

PostgreSQL 12rc1 copy命令 binary格式导出data1表

postgres=# insert into data1 values(1,'aa');
INSERT 0 1
postgres=# copy data1 to 'd:\data1_bin.bin' binary;
COPY 1
postgres=# select version();
                           version
-------------------------------------------------------------
 PostgreSQL 12rc1, compiled by Visual C++ build 1900, 64-bit
(1 row)


postgres=#


PostgreSQL 11.5 copy命令 binary格式导入data1表

postgres=# create table data1(c1 numeric,c2 varchar(10));
CREATE TABLE
postgres=# copy data1 from  'd:\data1_bin.bin' binary;
COPY 1
postgres=# select * from data1;
 c1 | c2
----+----
  1 | aa
(1 行记录)


postgres=# select version();
                          version
------------------------------------------------------------
 PostgreSQL 11.5, compiled by Visual C++ build 1914, 64-bit
(1 行记录)


postgres=#


PostgreSQL 10.1 copy命令 binary格式导入data1表

postgres=# copy s_lei.data1 from 'd:\data1_bin.bin';--->>>必须带binary格式,否则报如下错误
ERROR:  invalid input syntax for type numeric: "PGCOPY"
背景:  COPY data1, line 1, column c1: "PGCOPY"
postgres=# copy s_lei.data1 from 'd:\data1_bin.bin' binary;
COPY 1
postgres=# select * from s_lei.data1;
 c1 | c2
----+----
  1 | aa
(1 行记录)


postgres=# select version();
                                                version
--------------------------------------------------------------------------------------------------------
 PostgreSQL 10.1 on x86_64-pc-mingw64, compiled by gcc.exe (Rev5, Built by MSYS2 project) 4.9.2, 64-bit
(1 行记录)


postgres=#

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值