您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

导入CSV以仅更新表中的一列

导入CSV以仅更新表中的一列

您可以用来LOAD DATA INFILE将800,000行数据批量加载到临时表中,然后使用多表UPDATE语法将现有表连接到临时表并更新数量值。

例如:

CREATE TEMPORARY TABLE your_temp_table LIKE your_table;

LOAD DATA INFILE '/tmp/your_file.csv'
INTO TABLE your_temp_table
FIELDS TERMINATED BY ','
(id, product, sku, department, quantity);

UPDATE your_table
INNER JOIN your_temp_table on your_temp_table.id = your_table.id
SET your_table.quantity = your_temp_table.quantity;

DROP TEMPORARY TABLE your_temp_table;
其他 2022/1/1 18:16:36 有528人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶