开发者

replace when using enable-local-infile

开发者 https://www.devze.com 2023-02-19 04:01 出处:网络
I have the following line in a shell script: /usr/bin/mysql --enable-local-infile --host=localhost --password=pass --user=db db < file.sql

I have the following line in a shell script:

/usr/bin/mysql --enable-local-infile --host=localhost --password=pass --user=db db < file.sql

At the moment it adds new lines if a key is matching开发者_开发技巧. I want it to replace instead of adding new lines if a product part no already exists in a table.

I have added a unique index on the field but I'm not sure how to get the line above to replace if a key matches a row.


I think I've sorted this:

The sql file I'm importing has lines in the form:

load data local infile 'Products.txt' replace into table products fields terminated by '|' lines terminated by '\r\n' IGNORE 1 LINES;

this should replace on a matching key/index. As I've setup partno as a unique index this should replace data if I'm correct.

0

精彩评论

暂无评论...
验证码 换一张
取 消