将数据从redshift加载到postgresql,获取NULL值错误

时间:2019-04-03 15:44:21

标签: postgresql amazon-web-services

从redshift卸载带有双引号的csv文件中的数据,并尝试使用copy命令将数据从生成的csv文件加载到postgres表中。但出现错误,例如日期类型“ NULL”的输入语法无效。获取数字字段也出现同样的错误。

从redshift卸载命令:-

UNLOAD ('select * from t1.test') TO 's3://buckt_nm/pr/test/' 
       credentials 'aws_access_key_id=asc;aws_secret_access_key=hyu' 
       DELIMITER AS ',' ADDQUOTES ESCAPE null as 'NULL' parallel on gzip ALLOWOVERWRITE MAXFILESIZE 100 MB REGION 'ap-southeast-1';

由卸载命令生成的CSV文件:-

"1","abc","13.00","2019-04-03","2019-04-03 23:17:04
"2","NULL","14.OO","NULL","NULL"
"NULL","XYZ","NULL","NULL","2019-04-03 23:17:06"

用于postgres表的DDL

CREATE TABLE t1.test (
prod_id int,
prod_nm varchar(60),
pr_value numeric(2,2),
    l_date date,
last_change timestamp);

复制命令:-

COPY t1.test FROM STDIN WITH null as 'NULL' CSV DELIMITER ',' ESCAPE '/'

0 个答案:

没有答案