1.1 重排 auto_increment 的值
-1. 清空表时候用 truncate table_name 会自动将auto_increment 恢复为1;(不用delete from table_name)
-2. 或者清空表后用 alter table table_name auto_increment-1; //将表auto_increment设置为1;
2.1 正则表达式的使用
-1. $ 在字符串的末尾处进行匹配.
-2. . 匹配任意单个字符,包括换行符
-3. [....]匹配括号内任意的字符.
-4 a*匹配零个或多个a(包括空串)
-5. a+匹配1个或多个(不包括空串)
-6. a?匹配零个或1个a
-7. a1|a2 匹配a1或a2
-8. a(m) 匹配m个a
-9. a(m,)匹配至少m个a
-10. a(m,n)匹配m到n个a
-11. a(,n)匹配0到n个a
-12 (...)将模式元素组成单一元素
eg: select * from t1 where name regexp"[,.]@126.com$"; //查询t1表中name以.@126.com或,@126.com结尾的列.
等价于
eg: select * form t1 where name like"%.@126.com" or name like"%,@126.com";
// 注意使用正则表达式会增加消耗,所以建议使用 like
2.2 巧用rand()提取随机行
select * from t1 order by rand() limit 0 , 3; //随机抽取3条数据样本. 注意是随机哟.
2.3 利用group by 的with rillup 子句统计 , 会把每个分组再次统计和.
2.5 外键问题
注意: innodb类型的表可以支持外键,myisam类型的不支持外键.(不建议在MySQL中使用外键)