distinct关键字
distinct是应用于所有列的, 而不是某一个列
1 | mysql> select * from test_table; |
and关键字
and的组合优先级比or高
1 | mysql> select * from test_table; |
NULL
null和空字符是不一样的, 找到他和删除他的方式也比较特别
1 | mysql> insert into test_table(one , two) values (null, null); |
rollback
- 并不是什么都可以回滚的, 典型的如创建表和删除表这些都是不能回退的.
- 事务是用来管理 insert,update,delete 语句的
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36mysql> set autocommit = 0;
Query OK, 0 rows affected (0.00 sec)
mysql> select * from test_tab;
+-----+-----+-------+
| one | two | three |
+-----+-----+-------+
| 3 | 4 | 5 |
+-----+-----+-------+
1 row in set (0.00 sec)
mysql> set autocommit = 0;
Query OK, 0 rows affected (0.00 sec)
mysql> insert into test_tab value (4, 4, 5);
Query OK, 1 row affected (0.00 sec)
mysql> rollback;
Query OK, 0 rows affected (0.01 sec)
mysql> select * from test_tab;
+-----+-----+-------+
| one | two | three |
+-----+-----+-------+
| 3 | 4 | 5 |
+-----+-----+-------+
1 row in set (0.00 sec)
mysql> drop table test_tab;
Query OK, 0 rows affected (0.02 sec)
mysql> rollback;
Query OK, 0 rows affected (0.00 sec)
mysql> select * from test_tab;
ERROR 1146 (42S02): Table 'b_test_database.test_tab' doesn't exist