Syntax

SQL Use a Transaction Syntax

In SQL, use a transaction: groups statements so they all succeed or fail — BEGIN; ... COMMIT; -- or ROLLBACK;

Quick Answer

Syntax
BEGIN; ... COMMIT; -- or ROLLBACK;
SQLSyntax

Use a Transaction

Code example
BEGIN; ... COMMIT; -- or ROLLBACK;

Groups statements so they all succeed or fail.

Learn More

How to use a transaction in SQL

  1. Open your SQL file or editor.
  2. Copy the example, then replace its sample names and values for your code.

SQL Use a Transaction Syntax

Use BEGIN; ... COMMIT; -- or ROLLBACK;.

Related Syntax References

Frequently asked questions

What is the SQL syntax for use a transaction?

Use this pattern: BEGIN; ... COMMIT; -- or ROLLBACK;

Can I copy this SQL code example?

Yes. Use Copy code and adapt the example to your program.

Is this SQL syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify