Command line window one:
-- Set transaction not to commit automatically
set autocommit=0;
-- Query and lock the record with id='default'
select * from am_domain where id='default' for update;
Command line window two:
implement
select * from am_domain where id='default' for update;
or
update am_domain set ... where id='default';
or
delete from am_domain where id='domain';
All will be stuck, waiting for the lock to be released. Only after the "command line window 1" commits the transaction, the SQL statement in the "command line window 2" can continue.
illustrate:
When the command line window locks the specified record,
In window 2, ordinary select statements that do not contain for update can be executed normally.
In window 2, update SQL that does not involve locking records (id !='default') can also be executed.