[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Normally you will get an error when you try to INSERT
or
UPDATE
a row that causes a primary key, unique key or foreign key
violation. If you are using a transactional storage engine such as
InnoDB
, MySQL will automatically roll back the transaction. If you are
using a non-transactional storage engine, MySQL will stop at the incorrect
row and leave any remaining rows unprocessed.
To make life easier, MySQL supports an IGNORE
keyword for
most commands that can cause a key violation (such as INSERT IGNORE
and UPDATE IGNORE
). In this case, MySQL will ignore any key
violation and continue with processing the next row. You can get
information about what MySQL did with the mysql_info()
API function.
See section mysql_info()
.
In MySQL 4.1 and up, you also can use the SHOW WARNINGS
statement.
See section 13.5.3.9 SHOW WARNINGS | ERRORS
.
Note that for the moment only InnoDB
tables support foreign keys.
See section 14.4.5.2 FOREIGN KEY
Constraints.
Foreign key support in MyISAM
tables is scheduled for implementation
in MySQL 5.1.