整数为空值的 vertica 复制命令

vertica copy command with null value for Integer

是否可以将任何空字符放入 csv 中以放入空值

转化为整数列

不使用“,X”模式?

即(X是一个值,第一个为空)

假设您有一个这样的文件 /tmp/file.csv:

2016-01-10,100,abc
2016-02-21,,def
2017-01-01,300,ghi

和目标 table 定义如下:

create table t1 ( dt date, id integer, txt char(10));

然后,以下命令将在第二列(具有 dt='2016-02-21' 的列)的 "id" 中插入 NULL:

copy t1 from '/tmp/file.csv' delimiter ',' direct abort on error;

现在,如果您想使用 特殊字符串来识别输入文件中的 NULL 值,假设 'MYNULL':

2016-01-10,100,abc
2016-02-21,MYNULL,def
2017-01-01,300,ghi

然后...您必须 运行 以这种方式复制 COPY:

copy t1 from '/tmp/file.csv' delimiter ',' null 'MYNULL' direct abort on error;