首页 > 数据库技术 > 详细

mysql命令

时间:2019-09-02 22:39:22      阅读:113      评论:0      收藏:0      [点我收藏+]

1 连接

mysql -h host -u user -p password

2 创建和删除数据库

create database test;

drop database test;

3 创建和删除表

create table xxx();

drop table xxx;

4 mysql 默认不区分大小写

比如在where字句中,若想要区分大小写,则需要使用binary关键字表示区分大小写。

5 select / where / group by / having / order by的执行顺序

select->where->group by->having->order by

6 update 替换某个字段中的某个字符

update xxx set xx= replace(xxx, fromStr, toStr) where clause;

7 mysql中NULL值需要特殊处理

在mysql中,NULL值与任何其它值的比较都是false。mysql中处理NULL需要使用 is null 和 is not null。

8 模糊查询+正则查询

like字句:select * from test where uu like ‘%aaa%‘;  查找uu字段中含有aaa的的记录。

select * from test where uu like ‘%aaa‘; 查找uu字段中以aaa结尾的数据记录。

select * from test where uu like ‘aaa%‘; 查找uu字段中以aaa开头的数据记录。

select * from test where uu like ‘_o_‘; 查找uu字段中第二个字符是o的数据记录。

regexp:select * from test where uu regexp ‘^[aeiou]|haha$‘; 查找uu字段中以元音字符开头或者以haha结尾的记录。

 

mysql命令

原文:https://www.cnblogs.com/mydesky2012/p/11448925.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!