J0ANMM
J0ANMM

Reputation: 8525

SQLite: difference between 'INSERT OR REPLACE' and only 'REPLACE'

I've found many discussions about INSERT OR REPLACE and I thought it was clear to me, but after reading this article saying:

The following illustrates the syntax of the REPLACE statement.

INSERT OR REPLACE INTO table(column_list)
VALUES(value_list);

Or in a shorter form:

REPLACE INTO table(column_list)
VALUES(value_list);

I'm afraid I missed something.

Why is the INSERT statement needed together with REPLACE? Does it actually make any difference in examples like this one, for instance?

Upvotes: 1

Views: 462

Answers (1)

timclutton
timclutton

Reputation: 13004

When in doubt, consult the documentation (emphasis mine):

The REPLACE command is an alias for the "INSERT OR REPLACE" variant of the INSERT command. This alias is provided for compatibility other SQL database engines. See the INSERT command documentation for additional information.

Upvotes: 2

Related Questions