本文为mariadb官方手册:wait/nowait的译文。
原文:https://mariadb.com/kb/en/library/wait-and-nowait/
我提交到MariaDB官方手册的译文:https://mariadb.com/kb/zh-cn/wait-and-nowait/
从MariaDB 10.3.0开始,引入扩展语法以便下面的语句可以使用innodb_lock_wait_timeout
变量和lock_wait_timeout
变量设置的锁等待时长:
Syntax
ALTER TABLE tbl_name [WAIT n|NOWAIT] ...
CREATE ... INDEX ON tbl_name (index_col_name, ...) [WAIT n|NOWAIT] ...
DROP INDEX ... [WAIT n|NOWAIT]
DROP TABLE tbl_name [WAIT n|NOWAIT] ...
LOCK TABLE ... [WAIT n|NOWAIT]
OPTIMIZE TABLE tbl_name [WAIT n|NOWAIT]
RENAME TABLE tbl_name [WAIT n|NOWAIT] ...
SELECT ... FOR UPDATE [WAIT n|NOWAIT]
SELECT ... LOCK IN SHARE MODE [WAIT n|NOWAIT]
TRUNCATE TABLE tbl_name [WAIT n|NOWAIT]
Description
锁等待超时时长可以通过WAIT n
(单位为秒)来精确设置,或者设置为NOWAIT
,这种情况下,如果无法获取锁会立即返回失败。WAIT 0
等价于NOWAIT
。