Records: 1
Warnings occur under the same circumstances as when values are inserted using the
statement (see
warnings when there are too few or too many fields in the input row.
You can use
information about what went wrong. See
If you are using the C API, you can get information about the statement by calling the
function. See
13.2.7.
REPLACE
REPLACE [LOW_PRIORITY | DELAYED]
[INTO]
tbl_name
{VALUES | VALUE}
Or:
REPLACE [LOW_PRIORITY | DELAYED]
[INTO]
tbl_name
SET
col_name={expr
Or:
REPLACE [LOW_PRIORITY | DELAYED]
[INTO]
tbl_name
SELECT ...
works exactly like INSERT, except that if an old row in the table has the same value as a new
REPLACE
row for a
PRIMARY KEY
Section 13.2.5,
is a MySQL extension to the SQL standard. It either inserts, or deletes and inserts. For
REPLACE
another MySQL extension to standard SQL—that either inserts or updates—see
"INSERT ... ON DUPLICATE KEY UPDATE
Note that unless the table has a
no sense. It becomes equivalent to INSERT, because there is no index to be used to determine
whether a new row duplicates another.
Values for all columns are taken from the values specified in the
missing columns are set to their default values, just as happens for INSERT. You cannot refer
to values from the current row and use them in the new row. If you use an assignment such as
SET col_name = col_name +
treated as
DEFAULT(col_name)
DEFAULT(col_name) +
To use REPLACE, you must have both the
The
REPLACE
rows deleted and inserted. If the count is 1 for a single-row REPLACE, a row was inserted and no rows
were deleted. If the count is greater than 1, one or more old rows were deleted before the new row was
inserted. It is possible for a single row to replace more than one old row if the table contains multiple
unique indexes and the new row duplicates values for different old rows in different unique indexes.
The affected-rows count makes it easy to determine whether
also replaced any rows: Check whether the count is 1 (added) or greater (replaced).
If you are using the C API, the affected-rows count can be obtained using the
mysql_affected_rows()
Deleted: 0
Skipped: 0
Section 13.2.5,
"INSERT
to get a list of the first
SHOW WARNINGS
Section 20.6.6.35,
"mysql_info()".
Syntax
[(col_name,...)]
({expr
| DEFAULT},...),(...),...
| DEFAULT}, ...
[(col_name,...)]
or a
UNIQUE
"INSERT
Syntax".
PRIMARY KEY
1, the reference to the column name on the right hand side is
[965], so the assignment is equivalent to
1.
statement returns a count to indicate the number of rows affected. This is the sum of the
function.
Syntax
REPLACE
Warnings: 0
Syntax"), except that
max_error_count
Section 13.7.5.37,
"SHOW WARNINGS
index, the old row is deleted before the new row is inserted. See
Syntax".
or
index, using a
UNIQUE
[577]
and
INSERT
1081
LOAD DATA INFILE
[468]
warnings as
Syntax".
Section 13.2.5.3,
REPLACE
statement. Any
REPLACE
SET col_name =
[577]
privileges for the table.
DELETE
only added a row or whether it
REPLACE
INSERT
also generates
mysql_info()
statement makes
Need help?
Do you have a question about the 5.0 and is the answer not in the manual?
Questions and answers