MySQL索引失效行锁变表锁

    科技2022-07-11  100

    create table test_lock ( id int, name varchar(255), primary key (id), unique (name) )ENGINE=InnoDB default charset=utf8mb4; insert test_lock values(1,'1001'),(2,'1002'),(3,'1003'),(4,'1004'); 事务1 set autocommit=0; update test_lock set id = 10 where name = 1002; --隐式类型转换,索引失效,行锁变表锁 commit; 事务2 set autocommit=0; update test_lock set name='1099' where id = 4; -- 此时阻塞 commit;
    Processed: 0.008, SQL: 8