Collections:
RELEASE_ALL_LOCKS() - Release All Locks
How to release all locks associated with the current connection session using the RELEASE_ALL_LOCKS() function?
✍: FYIcenter.com
RELEASE_ALL_LOCKS(lock) is a MySQL built-in function that
releases all locks associated with the current connection session.
It returns the number of locks released.
For example:
SELECT GET_LOCK('MyLockX', 60), GET_LOCK('MyLockY', 60);
-- +-------------------------+-------------------------+
-- | GET_LOCK('MyLockX', 60) | GET_LOCK('MyLockY', 60) |
-- +-------------------------+-------------------------+
-- | 1 | 1 |
-- +-------------------------+-------------------------+
SELECT IS_USED_LOCK('MyLockX'), IS_USED_LOCK('MyLockY');
-- +-------------------------+-------------------------+
-- | IS_USED_LOCK('MyLockX') | IS_USED_LOCK('MyLockY') |
-- +-------------------------+-------------------------+
-- | 307 | 307 |
-- +-------------------------+-------------------------+
SELECT RELEASE_ALL_LOCKS();
-- +---------------------+
-- | RELEASE_ALL_LOCKS() |
-- +---------------------+
-- | 2 |
-- +---------------------+
SELECT IS_USED_LOCK('MyLockX'), IS_USED_LOCK('MyLockY');
-- +-------------------------+-------------------------+
-- | IS_USED_LOCK('MyLockX') | IS_USED_LOCK('MyLockY') |
-- +-------------------------+-------------------------+
-- | NULL | NULL |
-- +-------------------------+-------------------------+
Note that when a session connection is terminated, all locks associated with the connection will be released automatically.
Reference information of the RELEASE_ALL_LOCKS() function:
RELEASE_ALL_LOCKS(): count releases all locks associated with the current connection session, and returns the number of locks released. Arguments, return value and availability: count: Return value. Number of locks released. Available since MySQL 4.
Related MySQL functions:
⇒ RELEASE_LOCK() - Release Lock Instance
⇐ NULLIF() - NULL on Equal Values
2023-12-20, 1111🔥, 0💬
Popular Posts:
How To Verify a User name with SQLCMD Tool in SQL Server? The quickest way to verify a user name in ...
How To Locate and Take Substrings with CHARINDEX() and SUBSTRING() Functions in SQL Server Transact-...
How To Use DATEADD() Function in SQL Server Transact-SQL? DATEADD() is a very useful function for ma...
How To Recover a Dropped Index in Oracle? If you have the recycle bin feature turned on, dropped ind...
How To Replace Given Values with NULL using NULLIF() in SQL Server Transact-SQL? Sometime you want t...