Oracle 5.0 Reference Manual page 1089

Table of Contents

Advertisement

[ ON DUPLICATE KEY UPDATE col_name=expr, ... ]
With
INSERT ...
For example:
INSERT INTO tbl_temp2 (fld_id)
SELECT tbl_temp1.fld_order_id
FROM tbl_temp1 WHERE tbl_temp1.fld_order_id > 100;
The following conditions hold for a
• Specify
IGNORE
DELAYED
• The target table of the
query. (This was not possible in some older versions of MySQL.) However, you cannot insert into a
table and select from the same table in a subquery.
When selecting from and inserting into a table at the same time, MySQL creates a temporary table
to hold the rows from the
remains true that you cannot use
TEMPORARY
(see
Section C.5.7.2,
AUTO_INCREMENT
• To ensure that the binary log can be used to re-create the original tables, MySQL does not permit
concurrent inserts for
• To avoid ambiguous column reference problems when the
same table, provide a unique alias for each table used in the
names in that part with the appropriate alias.
In the values part of
as you do not use
column names in the values part.
The order in which rows are returned by a
determined. This means that, when using replication, there is no guarantee that such a
rows in the same order on the master and the slave; this can lead to inconsistencies between them.
To prevent this from occurring, you should always write
be replicated as
matter as long as the same order for returning the rows is enforced on both the master and the slave.
See also
Section 16.4.1.9, "Replication and
13.2.5.2.
INSERT DELAYED
INSERT DELAYED ...
The
DELAYED
useful if you have clients that cannot or need not wait for the
situation when you use MySQL for logging and you also periodically run
statements that take a long time to complete.
When a client uses
to be inserted when the table is not in use by any other thread.
Another major benefit of using
together and written in one block. This is much faster than performing many separate inserts.
Note that
INSERT DELAYED
is also the additional overhead for the server to handle a separate thread for each table for which there
SELECT, you can quickly insert many rows into a table from one or many tables.
INSERT ... SELECT
to ignore rows that would cause duplicate-key violations.
is ignored with
INSERT ...
statement may appear in the
INSERT
SELECT
table, because
TEMPORARY
"TEMPORARY
columns work as usual.
INSERT ... SELECT
ON DUPLICATE KEY
in the
GROUP BY
INSERT ... SELECT ... ORDER BY
Syntax
option for the
INSERT
DELAYED, it gets an okay from the server at once, and the row is queued
INSERT
INSERT DELAYED
is slower than a normal
Syntax
INSERT
statements:
SELECT.
and then inserts those rows into the target table. However, it
INSERT INTO t ... SELECT ... FROM t
tables cannot be referred to twice in the same statement
Table
Problems").
statements.
UPDATE, you can refer to columns in other tables, as long
part. One side effect is that you must qualify nonunique
SELECT
statement with no
SELECT
INSERT ... SELECT
column. The choice of
LIMIT".
statement is a MySQL extension to standard SQL that is very
is that inserts from many clients are bundled
INSERT
1069
clause of the
FROM
SELECT
and the
SELECT
INSERT
part, and qualify column
SELECT
clause is not
ORDER BY
statements that are to
column
to complete. This is a common
INSERT
and
SELECT
if the table is not otherwise in use. There
part of the
when
is a
t
refer to the
returns
SELECT
does not
UPDATE

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents