简体   繁体   English

Crate.io复制从0行受影响

[英]Crate.io Copy From 0 rows affected

I have a Crate.io database, running CrateDB version 3.2.7, under Windows Server 2012. (I know it's not the best, it's only for testing purposes right now and will not be the final setup.) 我有一个在Windows Server 2012下运行CrateDB版本3.2.7的Crate.io数据库。(我知道它不是最好的,它仅用于测试目的,并且不是最终设置。)

I have create the table dbo.snapshots 我已经创建了表dbo.snapshots 在此处输入图片说明

I exported the data from SQL Server to a CSV file via the BCP command. 我通过BCP命令将数据从SQL Server导出到CSV文件。

bcp DatabaseName.dbo.Snapshots out F:\Path\dbo_OldSnapshots.dat -S ServerName -U UserName -P Password -a65535 -c -C 65001 -t ,

Then I tried to import the data into CrateDb with the "COPY FROM" command. 然后,我尝试使用“ COPY FROM”命令将数据导入CrateDb。

COPY dbo.snapshots FROM 'file:///F:/Path/dbo_OldSnapshots.dat';

The file is about 11go big. 该文件大约11go。 I know it found the file, as I could see the I/O on the drive in Task Manager. 我知道它找到了文件,因为我可以在任务管理器中看到驱动器上的I / O。

It ran for about 13 minutes, and then said "0 rows affected". 它运行了大约13分钟,然后说“ 0行受影响”。 I have no idea why it didn't work, I didn't get any errors. 我不知道为什么它不起作用,我没有得到任何错误。

在此处输入图片说明 Any idea what I can do to make it work? 知道我可以做些什么来使其工作吗?

********************************* EDITED ADDED ADDITIONAL INFO **************************** **************************************编辑后的附加信息************* ***************
Ok, so I've found out that you can specify the "RETURN SUMMARY" clause at the end of the COPY command. 好的,所以我发现您可以在COPY命令的末尾指定“ RETURN Summary”子句。 I tested it with a smaller file. 我用一个较小的文件进行了测试。

With that, I got an error that says that the primary key cannot be NULL. 这样,我得到一个错误,指出主键不能为NULL。 I know that it's not NULL in the data that I extract, so I'm gonna have to find out why it says that my primary key is NULL. 我知道在提取的数据中它不是NULL,所以我将不得不找出为什么它说我的主键是NULL。

So I changed the BCP delimiter to be a comma, since the CSV file for CrateDB must be comma separated, and I manually edited the file to add the column headers since CrateDB asks for a header. 因此,我将BCP分隔符更改为逗号,因为CrateDB的CSV文件必须用逗号分隔,并且由于CrateDB要求输入标题,因此我手动编辑了该文件以添加列标题。

I also edited the file in Notepadd++ to save it in UTF-8 encoding, to make sure it was the right encoding. 我还用Notepadd ++编辑了文件,以UTF-8编码保存,以确保它是正确的编码。

But even with all that, I still get the error saying that the primary key value must not be NULL. 但是尽管如此,我仍然收到错误消息,指出主键值不能为NULL。

在此处输入图片说明

Ok so I managed to make it work. 好的,所以我设法使其工作。 Here is what you need to check if you try to Export data from SQL or another dbms to CrateDB : 如果您尝试将数据从SQL或其他dbms导出到CrateDB,则需要检查以下内容:

- File encoding in UTF-8 -UTF-8中的文件编码

- Comma separated file -逗号分隔文件

- The first line needs to be a header with all the columns be carefull, the names are case sensitive so if the column is "MyColumn" in SQL Server, but "mycolumn" in CrateDB, it must be in lower case in the header or else CrateDb won't be able to find it correctly -第一行必须是标题,所有列都要小心,名称区分大小写,因此,如果列在SQL Server中为“ MyColumn”,但在CrateDB中为“ mycolumn”,则在标题或标题中必须小写否则CrateDb将无法正确找到它

- If you have DateTime types, it must be between "" in the file (ex: 1,0,"2019-05-10T16:40:00",0,0) -如果您有DateTime类型,则该日期必须在文件中的“”之间(例如:1,0,“ 2019-05-10T16:40:00”,0,0)

- If you have DateTime types, please note that you need to have T between the date and time part. -如果您有DateTime类型,请注意,您需要在日期和时间部分之间使用T。 So "2019-05-10T16:40:00" instead of "2019-05-10 16:40:00" 所以是“ 2019-05-10T16:40:00”而不是“ 2019-05-10 16:40:00”

With all of that in check, I was able to import a sample data in my CrateDB database. 进行所有检查后,我便能够在CrateDB数据库中导入示例数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM