学习数据库的记录.
1.
LOAD DATA LOCAL INFILE '/Users/cancer/Desktop/pet.txt' INTO TABLE pet LINES TERMINATED BY '\r\n';
用于将pet.txt的内容写入文档,pet内容如下
Whistler Gwen bird \N 1997-12-09
注:每个字段的值应该用tab隔开,否则一行信息将录入第一个字段值.
2.DISTINCT
distinct 关键字可以将选择的字段去重复.
eg.
select owner from pet
+-------+
| owner |
+-------+
| NULL |
| NULL |
| NULL |
| NULL |
| NULL |
| Diane |
| Diane |
| Gwen |
+-------+
select distinct owner from pet
+-------+
| owner |
+-------+
| NULL |
| Diane |
| Gwen |
+-------+
3.REGEXP
REGEXP 表示使用正则表达式去匹配
eg.
select name from pet where name regexp '^.{8}$'
匹配名字为8个字符的值.