#JDBC 命令行验证MySQL的隔离级别 root
CREATE USER tom IDENTIFIED BY '123456';
SHOW DATABASES;
GRANT SELECT,INSERT,UPDATE,DELETE ON test.* TO tom@'%';
USE test;
SELECT * FROM user_table WHERE user = 'CC';
SET AUTOCOMMIT = FALSE;
SELECT @@transaction_isolation;
#REPEATABLE-READ
SELECT * FROM user_table WHERE user = 'CC'; #2000
SELECT * FROM user_table WHERE user = 'CC'; #2000
SELECT * FROM user_table WHERE user = 'CC'; #2000
COMMIT;
SELECT * FROM user_table WHERE user = 'CC'; #3000
SET GLOBAL TRANSACTION ISOLATION LEVEL READ COMMITTED;
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
SELECT @@transaction_isolation;
SET AUTOCOMMIT = FALSE;
USE test;
#READ-COMMITTED
SELECT * FROM user_table WHERE user = 'CC'; #3000
SELECT * FROM user_table WHERE user = 'CC'; #3000
SELECT * FROM user_table WHERE user = 'CC'; #4000
COMMIT;
SET GLOBAL TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
SELECT @@transaction_isolation;
SET AUTOCOMMIT = FALSE;
#READ-UNCOMMITTED
SELECT * FROM user_table WHERE user = 'CC'; #4000
SELECT * FROM user_table WHERE user = 'CC'; #5000
SELECT * FROM user_table WHERE user = 'CC'; #4000
#JDBC 命令行验证MySQL的隔离级别 tom
SHOW DATABASES;
SHOW DATABASES;
USE test;
SELECT * FROM user_table WHERE user = 'CC';
SET AUTOCOMMIT = FALSE;
SELECT @@transaction_isolation;
#REPEATABLE-READ
SELECT * FROM user_table WHERE user = 'CC'; #2000
UPDATE user_table SET balance = 3000 WHERE user = 'CC';
SELECT * FROM user_table WHERE user = 'CC'; #3000
COMMIT;
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
SELECT @@transaction_isolation;
SET AUTOCOMMIT = FALSE;
USE test;
#READ-COMMITTED
SELECT * FROM user_table WHERE user = 'CC'; #3000
UPDATE user_table SET balance = 4000 WHERE user = 'CC';
COMMIT;
SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
SELECT @@transaction_isolation;
SET AUTOCOMMIT = FALSE;
#READ-UNCOMMITTED
SELECT * FROM user_table WHERE user = 'CC'; #4000
UPDATE user_table SET balance = 5000 WHERE user = 'CC';
ROLLBACK;
SELECT * FROM user_table WHERE user = 'CC'; #4000