【MySQL学习之路】
2020-03-24 本文已影响0人
Du1in9
0x01 登录
cd到bin目录,mysql -uroot -p,输入密码
![](https://img.haomeiwen.com/i21107801/635d5ccd58c207f5.png)
0x02 展示数据库,创建数据表
show databases;
![](https://img.haomeiwen.com/i21107801/0b4c0477180da9d4.png)
表名为person,字段id,name,gender
![](https://img.haomeiwen.com/i21107801/987e9e9ab54f54c4.png)
0x03 插入数据
insert into `person` values (1,'Zhao','man'),(2,'Qian','woman'),(3,'Sun','man'),(4,'Li','woman');
select * from `person`;
![](https://img.haomeiwen.com/i21107801/e83e4afa1ef05938.png)
0x04 修改数据
修改Zhao的id为2333,update person set id =2333 where name='Zhao';
![](https://img.haomeiwen.com/i21107801/da2ce4e3e1721e1f.png)
修改Zhao的gender为???,update person set gender=replace(gender,'man','???') where id=2333;
![](https://img.haomeiwen.com/i21107801/939f2da971c0f293.png)
0x05 删除数据
删除id为2的数据,delete from `person` where id=2;
![](https://img.haomeiwen.com/i21107801/2e8df0fce37e7f03.png)
0x06 查找数据
查找后2行数据,select * from `person` limit 1,2;
![](https://img.haomeiwen.com/i21107801/58c164797ed06612.png)
按照name升序展示,select * from `person` order by name asc;
![](https://img.haomeiwen.com/i21107801/174f42b11f7a9be8.png)
按照name降序显示,select * from `person` order by name desc;
![](https://img.haomeiwen.com/i21107801/f59899354a19a00e.png)
条件查询,select * from `person` where name = 'Sun' ;
![](https://img.haomeiwen.com/i21107801/a8d9a3b4c5f75167.png)