Clarified REPLACE command a bit.
This commit is contained in:
parent
2006e29a85
commit
a682d70761
@ -34520,9 +34520,10 @@ or REPLACE [LOW_PRIORITY | DELAYED]
|
|||||||
@end example
|
@end example
|
||||||
|
|
||||||
@code{REPLACE} works exactly like @code{INSERT}, except that if an old
|
@code{REPLACE} works exactly like @code{INSERT}, except that if an old
|
||||||
record in the table has the same value as a new record on a unique index,
|
record in the table has the same value as a new record on a @code{UNIQUE}
|
||||||
the old record is deleted before the new record is inserted.
|
index or @code{PRIMARY KEY}, the old record is deleted before the new
|
||||||
@xref{INSERT, , @code{INSERT}}.
|
record is inserted.
|
||||||
|
@xref{INSERT, ,@code{INSERT}}.
|
||||||
|
|
||||||
In other words, you can't access the values of the old row from a
|
In other words, you can't access the values of the old row from a
|
||||||
@code{REPLACE} statement. In some old MySQL versions it appeared that
|
@code{REPLACE} statement. In some old MySQL versions it appeared that
|
||||||
@ -34536,6 +34537,10 @@ This fact makes it easy to determine whether @code{REPLACE} added
|
|||||||
or replaced a row: check whether the affected-rows value is 1 (added)
|
or replaced a row: check whether the affected-rows value is 1 (added)
|
||||||
or 2 (replaced).
|
or 2 (replaced).
|
||||||
|
|
||||||
|
Note that unless you use a @code{UNIQUE} index or @code{PRIMARY KEY},
|
||||||
|
using a @code{REPLACE} command makes no sense, since it would just do
|
||||||
|
an @code{INSERT}.
|
||||||
|
|
||||||
|
|
||||||
@node LOAD DATA, DO, REPLACE, Data Manipulation
|
@node LOAD DATA, DO, REPLACE, Data Manipulation
|
||||||
@subsection @code{LOAD DATA INFILE} Syntax
|
@subsection @code{LOAD DATA INFILE} Syntax
|
||||||
|
Loading…
x
Reference in New Issue
Block a user