user517491
user517491

Reputation:

Mysql how to insert none or all rows - Revert all inserted in-case of error

Is there any built in way in mysql in which it either inserts all the given rows, or reverts all inserted rows if an error(eg duplicate error) occurs?

Upvotes: 1

Views: 65

Answers (2)

Neil
Neil

Reputation: 5780

What you're referring to is commonly called a transaction. You should begin a transaction and perform a series of inserts and rollback upon failure.

See this document for further details on transactions.

Upvotes: 1

yan.kun
yan.kun

Reputation: 6908

The keyword you are looking for is transaction.

Upvotes: 2

Related Questions