DUPLICATES Clause (duplicates_clause)
The DUPLICATES
clause (duplicates_clause
)
can be used to determine how key collisions are handled.
Syntax
<duplicates_clause> ::=
REJECT DUPLICATES
| IGNORE DUPLICATES
| UPDATE DUPLICATESThe DUPLICATES
clause is used in
the SQL statements CREATE
TABLE statement and INSERT statement.
|
The |
|
Any rows that cause key collisions on insertion are ignored. |
|
Any rows that cause key collisions on insertion overwrite the rows with which they collide. |
If there is already a row in the base table with the key of the row to be inserted, the following cases must be distinguished:
|
The |
|
The new row is not inserted and processing of the |
|
The existing row is overwritten by the new row and processing of
the |
If there is more than one key collision for the same key for an INSERT
statement
with UPDATE DUPLICATES
and QUERY
expression
specification, it is impossible to predict the content of the respective base
table row once the INSERT
statement has been
completed.
If, for an INSERT
statement with IGNORE
DUPLICATES
and a QUERY
expression,
more than one row in the result table produces the same base table key, and
if this key did not exist before in the base table, it is impossible to predict
the row that will be inserted in the table.
If the table name specified in the INSERT
statement
identifies a table without a user-defined key, the DUPLICATES
clause
has no effect.