1
A
回答
0
使用Unix/Windows上的Db2,可以使用IMPORT命令或LOAD命令。另外INGEST命令还可以使用其他方法。
使用IMPORT或LOAD,有两种方法可以使用“METHOD P”或在INSERT子句中指定目标列的顺序。下面有两个示例。
第一个例子使用“方法P”为导入:
有三个CSV文件,它们的三列是按照不同的顺序,并用三列的目标表(A,B,C):
create table mytab(a integer not null, b integer not null, c integer not null)
DB20000I The SQL command completed successfully.
!cat 1a.csv
1,2,3
!cat 1b.csv
99,98,97
!cat 1c.csv
55,51,59
import from 1a.csv of del method p(1,2,3) insert into mytab
SQL3109N The utility is beginning to load data from file "1a.csv".
SQL3110N The utility has completed processing. "1" rows were read from the
input file.
SQL3221W ...Begin COMMIT WORK. Input Record Count = "1".
SQL3222W ...COMMIT of any database changes was successful.
SQL3149N "1" rows were processed from the input file. "1" rows were
successfully inserted into the table. "0" rows were rejected.
Number of rows read = 1
Number of rows skipped = 0
Number of rows inserted = 1
Number of rows updated = 0
Number of rows rejected = 0
Number of rows committed = 1
import from 1b.csv of del method p(3,2,1) insert into mytab
SQL3109N The utility is beginning to load data from file "1b.csv".
SQL3110N The utility has completed processing. "1" rows were read from the
input file.
SQL3221W ...Begin COMMIT WORK. Input Record Count = "1".
SQL3222W ...COMMIT of any database changes was successful.
SQL3149N "1" rows were processed from the input file. "1" rows were
successfully inserted into the table. "0" rows were rejected.
Number of rows read = 1
Number of rows skipped = 0
Number of rows inserted = 1
Number of rows updated = 0
Number of rows rejected = 0
Number of rows committed = 1
import from 1c.csv of del method p(2,1,3) insert into mytab
SQL3109N The utility is beginning to load data from file "1c.csv".
SQL3110N The utility has completed processing. "1" rows were read from the
input file.
SQL3221W ...Begin COMMIT WORK. Input Record Count = "1".
SQL3222W ...COMMIT of any database changes was successful.
SQL3149N "1" rows were processed from the input file. "1" rows were
successfully inserted into the table. "0" rows were rejected.
Number of rows read = 1
Number of rows skipped = 0
Number of rows inserted = 1
Number of rows updated = 0
Number of rows rejected = 0
Number of rows committed = 1
select * from mytab
A B C
----------- ----------- -----------
1 2 3
97 98 99
51 55 59
3 record(s) selected.
第二个示例使用插入的有序列目标来匹配CSV文件中的列目标顺序。
create table mynewtab(a integer not null, b integer not null, c integer not null)
DB20000I The SQL command completed successfully.
!cat 1a.csv
1,2,3
!cat 1b.csv
99,98,97
!cat 1c.csv
55,51,59
import from 1a.csv of del insert into mynewtab(a,b,c)
SQL3109N The utility is beginning to load data from file "1a.csv".
SQL3110N The utility has completed processing. "1" rows were read from the
input file.
SQL3221W ...Begin COMMIT WORK. Input Record Count = "1".
SQL3222W ...COMMIT of any database changes was successful.
SQL3149N "1" rows were processed from the input file. "1" rows were
successfully inserted into the table. "0" rows were rejected.
Number of rows read = 1
Number of rows skipped = 0
Number of rows inserted = 1
Number of rows updated = 0
Number of rows rejected = 0
Number of rows committed = 1
import from 1b.csv of del insert into mynewtab(c,b,a)
SQL3109N The utility is beginning to load data from file "1b.csv".
SQL3110N The utility has completed processing. "1" rows were read from the
input file.
SQL3221W ...Begin COMMIT WORK. Input Record Count = "1".
SQL3222W ...COMMIT of any database changes was successful.
SQL3149N "1" rows were processed from the input file. "1" rows were
successfully inserted into the table. "0" rows were rejected.
Number of rows read = 1
Number of rows skipped = 0
Number of rows inserted = 1
Number of rows updated = 0
Number of rows rejected = 0
Number of rows committed = 1
import from 1c.csv of del insert into mynewtab(b,a,c)
SQL3109N The utility is beginning to load data from file "1c.csv".
SQL3110N The utility has completed processing. "1" rows were read from the
input file.
SQL3221W ...Begin COMMIT WORK. Input Record Count = "1".
SQL3222W ...COMMIT of any database changes was successful.
SQL3149N "1" rows were processed from the input file. "1" rows were
successfully inserted into the table. "0" rows were rejected.
Number of rows read = 1
Number of rows skipped = 0
Number of rows inserted = 1
Number of rows updated = 0
Number of rows rejected = 0
Number of rows committed = 1
select * from mynewtab
A B C
----------- ----------- -----------
1 2 3
97 98 99
51 55 59
3 record(s) selected.
相关问题
- 1. 结合几行的CSV文件导入基于一定条件
- 2. 如何将多个csv文件合并为一个CSV文件
- 3. 如何使用.NET将CSV文件导入DB2数据库?
- 4. 如何导入csv文件
- 5. 合并几个pdf文件
- 6. 如何合并几百列在CSV与Python文件
- 7. 合并两个csv文件
- 8. 合并多个CSV文件
- 9. 合并2个csv文件
- 10. 合并两个CSV文件
- 11. 合并多个CSV文件
- 12. 合并多个csv文件
- 13. 合并几个csv文件并将文件名存储为变量 - Python
- 14. 如何将多个csv文件合并为1个SAS文件
- 15. 导入* .csv并合并工作表
- 16. 导入几个csv文件并使用熊猫在Python中连接
- 17. 在几个文本文件合并列
- 18. 合并多个的.csv文件合并成一个
- 19. 如何使用PHP将3个CSV文件合并为1个CSV文件?
- 20. 从csv导入几行R
- 21. PHP写入csv文件合并标头
- 22. 导入CSV文件
- 23. 导入CSV文件
- 24. 如何合并两个文本文件,并转换成csv文件斯卡拉
- 25. 从db2表中的csv文件导入数据
- 26. 导入CSV文件,并使用VB2008
- 27. 写入CSV文件并将其导出?
- 28. Python - 合并从csv文件导入的Dask数据框
- 29. 合并几个事件
- 30. 导入几个文本文件到R
是Unix/Linux上运行的Windows的DB2服务器? – mao