Transactions

SQL SAVEPOINT

Mark a point within a transaction to which work can be rolled back.

Availability: Common SQL with references for SQL standard, MySQL/MariaDB, PostgreSQL, SQL Server, SQLite and Oracle Database; syntax and feature support vary by engine and version.中文

Syntax

SAVEPOINT savepoint_name;

Examples

Example (standard-style syntax). Verify supported keywords in your database.

SAVEPOINT before_optional_change;

SQLite-oriented variant; dialect behaviour may differ.

SAVEPOINT before_optional_change;

Parameters, options and clauses

Option / clauseDescription
BEGIN / START TRANSACTIONStart a transaction; exact keywords vary by engine.
COMMITMake the transaction's changes permanent.
ROLLBACKUndo uncommitted work or return to a savepoint.
SAVEPOINTMark an intermediate point within a transaction.
Isolation levelChoose concurrency behaviour where supported.

Dialect references

Safety note

Review a command and its target before running it. Commands that alter files, services, accounts, disks, permissions or databases may be difficult to reverse. Test in a safe environment and keep backups.

Official reference ↗Back to directory