简体   繁体   English

mysql workbench,从文件替换列

[英]mysql workbench, replace column from file

I have a 1,000,000 row .csv file that I uploaded into a table using mySQL Workbench, but I forgot to makes the dates YYYY-MM-DD before I started, so they all uploaded as 0000-00-00 . 我有一个1,000,000行的.csv文件,我使用mySQL Workbench上传到一个表中,但我忘记在开始之前将日期设为YYYY-MM-DD ,所以他们都上传了as 0000-00-00

It took almost 8 hours to upload the million records, so I'd REALLY like to not have to do it all over again, but I can't figure out if there's a way for me to replace JUST that one column of data from the same file I originally uploaded, now that I've changed the dates to be in the correct format. 上传百万条记录花了将近8个小时,所以我真的不想重新做一遍,但我无法弄清楚是否有办法让我替换JUST的一列数据我最初上传的同一个文件,现在我已将日期更改为正确的格式。

Does anyone know if this is possible? 有谁知道这是否可能?

Edit 编辑

It's WAY too long to post everything, but: here's the show create table with some of the meat taken out: 发布所有内容的时间太长了,但是:这是show create table ,其中包含一些肉:

CREATE TABLE myTable
(   lineID int(11) NOT NULL AUTO_INCREMENT,
    1 varchar(50) DEFAULT NULL,
    2 varchar(1) DEFAULT NULL,
    3 int(4) DEFAULT NULL,
    4 varchar(20) DEFAULT NULL,
    DATE date DEFAULT NULL,
    PRIMARY KEY (lineID)
) ENGINE=InnoDB AUTO_INCREMENT=634205 DEFAULT CHARSET=utf8

Version is 5.6.20 版本是5.6.20

Screenshot: 截图: 在此输入图像描述

Ok. 好。 I would recommend using LOAD DATA INFILE explicitly. 我建议明确使用LOAD DATA INFILE For those that have not used it, consider it just as a select statement for now til you see it. 对于那些没有使用它的人来说,现在考虑它只是一个选择语句,直到你看到它。

Here is a nice article on performance and strategies titled Testing the Fastest Way to Import a Table into MySQL . 这是一篇关于性能和策略的好文章,名为“ 测试将表格导入MySQL的最快方法” Don't let the mysql version of the title or inside the article scare you away. 不要让标题的mysql版本或文章内部吓跑你。 Jumping to the bottom and picking up some conclusions: 跳到最底层并得出一些结论:

The fastest way you can import a table into MySQL without using raw files is the LOAD DATA syntax. 在不使用原始文件的情况下将表导入MySQL的最快方法是LOAD DATA语法。 Use parallelization for InnoDB for better results, and remember to tune basic parameters like your transaction log size and buffer pool. 使用InnoDB的并行化以获得更好的结果,并记住调整基本参数,如事务日志大小和缓冲池。 Careful programming and importing can make a >2-hour problem became a 2-minute process. 仔细的编程和导入可以使> 2小时的问题成为一个2分钟的过程。 You can disable temporarily some security features for extra performance 您可以暂时禁用某些安全功能以获得额外性能

There are also fine points in there, mainly in peer comments back and forth about secondary indexes (which you do not have). 还有一些优点,主要是关于二级索引(你没有)的来回同行评论。 The important point for others is to add them after the fact. 其他人的重点是在事后添加它们。

I hope these links are useful. 我希望这些链接很有用。 And your data comes in ... in 10 minutes (in another test table with LOAD DATA INFILE ). 并且您的数据在10分钟内进入......(在另一个带有LOAD DATA INFILE测试表中)。

General Comments 普通的留言

About the slowest way to do it is in a programming language via a while loop, row by row. 关于最慢的方法是通过while循环逐行编程语言。 Getting faster is certainly batch, where one insert statement passes along, say, 200 to 1k rows at a time. 获得更快肯定是批处理的,其中一个插入语句一次传递200到1k行。 Up substantially in performance is LOAD DATA INFILE. 性能基本上是LOAD DATA INFILE。 Fastest is raw files (what I do, but beyond the scope of talking here). 最快的是原始文件(我做的,但超出了在这里讨论的范围)。

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

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