eclipse 如何将电子表格导入 DB2?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17724831/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 21:48:35  来源:igfitidea点击:

How do you import a spreadsheet into DB2?

eclipsedb2etl

提问by Jess

I have a CSV file, but this could apply to any txt, data, or xls file. (xlsx) I have exported the data from one source and I want to import the data into a DB2 table.

我有一个 CSV 文件,但这适用于任何 txt、数据或 xls 文件。(xlsx) 我已经从一个来源导出了数据,我想将数据导入到 DB2 表中

I first tried Data Tools Plugin (DTP)in eclipse Helios (3.6.3) by right clicking on the table and selecting: Data > Load...

我首先在 eclipse Helios (3.6.3) 中尝试了Data Tools Plugin (DTP),方法是右键单击表格并选择:Data > Load...

But I got this error:

但我收到了这个错误:

Loading "myschema"."mytable"... com.ibm.db2.jcc.am.SqlException: [jcc][10103][10941][4.14.113] Method executeQuery cannot be used for update. ERRORCODE=-4476, SQLSTATE=null Data loading failed.

正在加载“myschema”.“mytable”... com.ibm.db2.jcc.am.SqlException: [jcc][10103][10941][4.14.113] 方法 executeQuery 不能用于更新。ERRORCODE=-4476,SQLSTATE=null 数据加载失败。

Then I tried Eclipse SQL Exploreron Eclipse Juno, but it does not support data import.

然后我在 Eclipse Juno 上尝试了Eclipse SQL Explorer,但它不支持数据导入

How do I get past this error so I can import?

如何克服此错误以便导入?

采纳答案by Jess

I solved this by installing Eclipse Juno (4.2)and Data Tools Plugin (DTP) 1.10.2.

我通过安装Eclipse Juno (4.2)Data Tools Plugin (DTP) 1.10.2解决了这个问题。

Now Data > Load...will work fine. This is the new message I get:

现在数据>加载...将正常工作。这是我收到的新消息:

Data loading was successful. 142 row(s) loaded. 135 row(s) could not be loaded.

com.ibm.db2.jcc.am.go: DB2 SQL Error: SQLCODE=-407, SQLSTATE=23502, SQLERRMC= , DRIVER=4.7.85 One or more values could not be set in the following column(s): USER_TIME, USER_DATE

数据加载成功。已加载 142 行。135 行无法加载。

com.ibm.db2.jcc.am.go:DB2 SQL 错误:SQLCODE=-407,SQLSTATE=23502,SQLERRMC=,DRIVER=4.7.85 无法在以下列中设置一个或多个值:USER_TIME , USER_DATE



FYI for the entire process I was using this:

仅供参考我使用的整个过程:

  • DB2 driver: /opt/IBM/db2/V9.7/java
  • With jar files: db2jcc4.jar, db2jcc_license_cisuz.jar
  • Driver Class: com.ibm.db2.jcc.DB2Driver
  • DB2 驱动程序:/opt/IBM/db2/V9.7/java
  • 带有 jar 文件:db2jcc4.jar、db2jcc_license_cisuz.jar
  • 驱动程序类:com.ibm.db2.jcc.DB2Driver

回答by AngocA

You can import a CSV file directly into DB2 via the IMPORT or LOAD command, even with XML or BLOB as part of the data to import.

您可以通过 IMPORT 或 LOAD 命令将 CSV 文件直接导入 DB2,甚至可以将 XML 或 BLOB 作为要导入的数据的一部分。

The procedure to import depends on the structure of the file you are going to import. Probably you should modify the default behaviour of these commands; DB2 has many option to adapt the command to the input file.

导入的过程取决于您要导入的文件的结构。可能您应该修改这些命令的默认行为;DB2 有许多选项可以使命令适应输入文件。

For more information about:

有关更多信息:

I think your question was more oriented to: how to use Eclipse to import data in DB2 from a CSV file. However, as I said, you can do that directly via DB2.

我认为您的问题更侧重于:如何使用 Eclipse 从 CSV 文件中导入 DB2 中的数据。但是,正如我所说,您可以直接通过 DB2 来完成。

If you are going to import a file like the next one, the only thing that you need is to have access to a db2 client.

如果您要导入类似下一个文件的文件,您唯一需要的是能够访问 db2 客户端。

data.txt

数据.txt

1,"Andres","2013-05-18"
2,"Tom","2011-04-16"
3,"Jessica","2002-03-09"

You import with

你导入

db2 import from data.txt of del insert into test

回答by zawhtut

You can import using DB2 "Control Center" *

您可以使用 DB2“控制中心”导入*

Right Click the table and select "Import"

右键单击表格并选择“导入”

enter image description here

在此处输入图片说明

Then specify the csv file and message file message file is important because in the case of failed upload, you can find the error cause in the message file

然后指定csv文件和message文件message文件很重要,因为在上传失败的情况下,你可以在message文件中找到错误原因

enter image description here

在此处输入图片说明

*Control Center is now deprecated in favor of "Data Studio"

*控制中心现已弃用,取而代之的是“数据洞察

回答by Jonyx4

From the db2 console, try this:

从 db2 控制台,试试这个:

Import from 'yourcommaseparatedfile.csv' of del insert into "SCHEMA"."TABLE"

Regards =)

问候 =)

回答by Vikky

db2 'import from /users/n0sdsds/test.csv of del insert into ENTPRISE.tmp_x'