UNLOCK TABLES - MySQL


Overview

The UNLOCK TABLES command in MySQL releases all table locks currently held by the active session, enabling other sessions to access and modify the unlocked tables.

Syntax

UNLOCK TABLES

Options/Flags

None

Examples

Example 1: Unlocking all tables

UNLOCK TABLES;

Example 2: Releasing a specific table lock

UNLOCK TABLES tbl_name;

Common Issues

  • Error 1093: You are not allowed to unlock the given table(s): Occurs when the session does not hold a lock on the specified table.

Integration

  • With LOCK TABLES: Used after LOCK TABLES to release the acquired locks.
  • Transaction Management: UNLOCK TABLES is implicitly executed at the end of a commit or rollback operation.