I try to import to table data from sql files using command line. This data contents duplicates in filed url
.
But field url
in table is unique. So when I try to insert data I get error "Dublicate entry"
How to inmport all data skipping this error?
You can to use the --force (-f) flag.
mysql -u userName -p -f -D dbName < script.sql
From man mysql
:
· --force, -f
Continue even if an SQL error occurs.
How to inmport all data skipping this error?
Drop the index for time being -> run your batch insert -> recreate the index back
If you are using insert
, the you can ignore errors using ignore error
or on duplicate key update
(preferable because it only ignores duplicate key errors).
If you are using load data infile
, then you can use the ignore
key word. As described in the documentation :
If you specify
IGNORE
, rows that duplicate an existing row on a unique key value are discarded. For more information, see Comparison of the IGNORE Keyword and Strict SQL Mode.
Or, do as I would normally do:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.