ITPub博客

首页 > 数据库 > > HashData数据插入(integer DEFAULT NULL)

HashData数据插入(integer DEFAULT NULL)

作者:gaokeke123 时间:2022-02-16 14:45:30 0 删除 编辑

本章概要

通过 COPY 命令从文件中读取数据插入表中。当表中列为 integer 类型,并且文件中对应列为空。

实例
创建测试表 test:

drop table test;

create table test(id int,
"qycp_id" integer DEFAULT NULL)
distributed randomly;
1
2
3
4
5
创建测试导入文件 test.txt ,文件内容如下:

1|
2|2
1
2
执行插入,及报错信息:

hashdata=# copy test from '/home/gpadmin/test.txt' WITH DELIMITER '|' LOG ERRORS SEGMENT REJECT LIMIT 10 ROWS;
NOTICE: Found 1 data formatting errors (1 or more input rows). Rejected related input data.
COPY 1
1
2
3
修改 test.txt 文件中的空值
1|\N
2|2
1
2
执行插入,查看插入结果:

hashdata=# copy test from '/home/gpadmin/test.txt' WITH DELIMITER '|' LOG ERRORS SEGMENT REJECT LIMIT 10 ROWS;
COPY 2
hashdata=# select * from test;
id | qycp_id
----+---------
2 | 2
1 |
(2 rows)
1
2
3
4
5
6
7
8
数据成功插入。
————————————————
版权声明:本文为CSDN博主「GaryZhang000」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/zhang50303/article/details/81775050

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/26692020/viewspace-3168382/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
大家好

注册时间:2013-08-14

  • 博文量
    1432
  • 访问量
    31645