mysql的Insert in过程不会锁定表

mysql的Insert in过程不会锁定表,mysql,insert,locking,Mysql,Insert,Locking,我有一个mysql的过程: START TRANSACTION; insert into table1(id, name) values(1, 'a'); -- id is a primary key. ... delete from table1 where id = 1; COMMIT; 对该过程的多线程调用将在jdbc中显示错误 密钥表1的重复条目“1”\u唯一\u密钥“ 为什么另一个线程不等待此线程结束这是因为如果您选中,您已经将表声明为INODB引擎,它允许行级锁定,如果它是MYS

我有一个mysql的过程:

START TRANSACTION;

insert into table1(id, name) values(1, 'a'); -- id is a primary key.
...
delete from table1 where id = 1;
COMMIT;
对该过程的多线程调用将在jdbc中显示错误
密钥表1的重复条目“1”\u唯一\u密钥“


为什么另一个线程不等待此线程结束

这是因为如果您选中,您已经将表声明为
INODB
引擎,它允许行级锁定,如果它是
MYSAM
,则不会发生此问题