mysql transaction事务隔离级别的设置

mysql> set global transaction isolation level read committed;
mysql> start transaction;
Query OK, 0 rows affected (0.00 sec)

mysql> show tables;
±---------------+
| Tables_in_liu |
±---------------+
| data_vendor |
| employee |
| ju |
| org |
| orga |
| t_class |
| t_organization |
| t_student |
| t_teacher |
| t_user |
±---------------+
10 rows in set (0.00 sec)

mysql> desc t_student;
±--------±------------±-----±----±--------±------+
| Field | Type | Null | Key | Default | Extra |
±--------±------------±-----±----±--------±------+
| sno | int(3) | NO | PRI | NULL | |
| sname | varchar(32) | NO | | NULL | |
| classno | int(3) | YES | MUL | NULL | |
±--------±------------±-----±----±--------±------+
3 rows in set (0.01 sec)

mysql> insert into t_student(sno,sname) values(12,‘zhangli’);
Query OK, 1 row affected (0.01 sec)

mysql> select * from t_student;
±----±---------±--------+
| sno | sname | classno |
±----±---------±--------+
| 1 | lucy | 100 |
| 3 | king | 200 |
| 4 | Hanmeime | 200 |
| 5 | wangwu | 300 |
| 6 | lijun | 300 |
| 12 | zhangli | NULL |
±----±---------±--------+
6 rows in set (0.00 sec)

mysql> commit;
只有commit后,才能在另外的会话窗口查到
设置完事务隔离级别后退出才能起作用,隔离级别有read isolation(读未提交),read committed(读已提交),repeatable read(可重复读),serializable(串行化)四种

你可能感兴趣的:(学习笔记,mysql)