SQL Keywords

SQL RELEASE

What is SQL RELEASE?

Ends a savepoint within the current transaction so it can no longer be rolled back to.
Sign up to get up to date news on SQL keywords
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Compatible dialects for SQL RELEASE: PostgreSQL, MySQL, MariaDB, Oracle, SQL Server (as RELEASE SAVE TRANSACTION), IBM Db2. Not supported in SQLite.

SQL RELEASE Full Explanation

RELEASE SAVEPOINT permanently removes a previously defined savepoint from the transaction stack. After release, the transaction continues but the named savepoint is discarded, freeing the database engine from tracking it. Any changes made after the savepoint remain pending until a COMMIT or ROLLBACK occurs. Attempting to roll back to a released savepoint raises an error. RELEASE does not close or commit the outer transaction—it affects only the specified savepoint. The SQL:1999 standard introduced the SAVEPOINT/ROLLBACK TO/RELEASE trio for granular transaction control. Most enterprise databases follow the syntax "RELEASE SAVEPOINT name;" but SQL Server uses "RELEASE SAVE TRANSACTION name;" while PostgreSQL also permits the shorthand "RELEASE name;". The command must run inside an open transaction; otherwise, the database will return an error such as "no active transaction" or "SAVEPOINT does not exist".

SQL RELEASE Syntax

-- Standard SQL
RELEASE SAVEPOINT savepoint_name;

-- PostgreSQL shorthand
RELEASE savepoint_name;

-- SQL Server
RELEASE SAVE TRANSACTION savepoint_name;

SQL RELEASE Parameters

Example Queries Using SQL RELEASE

-- Example 1: PostgreSQL / Standard SQL
BEGIN;
SAVEPOINT sp_before_update;
UPDATE accounts SET balance = balance - 100 WHERE id = 1;
-- Keep the change and free resources
RELEASE SAVEPOINT sp_before_update;
COMMIT;

-- Example 2: MySQL
START TRANSACTION;
INSERT INTO orders(customer_id,total) VALUES (42, 250.00);
SAVEPOINT after_insert;
CALL validate_order( LAST_INSERT_ID() );
-- Validation passed, drop the savepoint
RELEASE SAVEPOINT after_insert;
COMMIT;

-- Example 3: SQL Server
BEGIN TRAN;
SAVE TRAN save_pt;
UPDATE products SET price = price*1.05;
RELEASE SAVE TRANSACTION save_pt;
COMMIT TRAN;

Expected Output Using SQL RELEASE

  • Database confirms success (e
  • g
  • , "RELEASE" in PostgreSQL, "Query OK" in MySQL)
  • The specified savepoint is deleted and cannot be referenced by future ROLLBACK TO statements

Use Cases with SQL RELEASE

  • Free transaction resources after a partial section is confirmed correct
  • Simplify logic in long-running transactions by discarding unneeded savepoints
  • Enforce business rules: validate data, then release the savepoint when checks succeed
  • Improve readability by marking milestones inside complex multi-step operations

Common Mistakes with SQL RELEASE

  • Releasing a savepoint outside an active transaction
  • Misspelling the savepoint name, leading to "does not exist" errors
  • Assuming RELEASE commits the whole transaction (it does not)
  • Trying to ROLLBACK TO a savepoint that has already been released

Related Topics

SAVEPOINT, ROLLBACK TO SAVEPOINT, COMMIT, ROLLBACK, BEGIN TRANSACTION

First Introduced In

SQL:1999

Frequently Asked Questions

Does RELEASE end my transaction?

No. It only removes a savepoint. You still need COMMIT or ROLLBACK to finish the transaction.

Can I release all savepoints at once?

No single command drops all savepoints. You must release each by name or commit/rollback the entire transaction.

How is RELEASE different from ROLLBACK TO SAVEPOINT?

RELEASE keeps all changes after the savepoint and deletes the savepoint, while ROLLBACK TO SAVEPOINT undoes changes back to that point and keeps the savepoint active.

Why use RELEASE at all?

Removing unneeded savepoints frees resources and clarifies transaction flow, especially in long or nested operations.

Sign up to get up to date news on SQL keywords
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.
Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo

Check out other commonly used SQL Keywords!