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.
精彩评论