【MySQL学习之路】
2020-03-24 本文已影响0人
Du1in9
0x01 登录
cd到bin目录,mysql -uroot -p,输入密码
0x02 展示数据库,创建数据表
show databases;
表名为person,字段id,name,gender
0x03 插入数据
insert into `person` values (1,'Zhao','man'),(2,'Qian','woman'),(3,'Sun','man'),(4,'Li','woman');
select * from `person`;
0x04 修改数据
修改Zhao的id为2333,update person set id =2333 where name='Zhao';
修改Zhao的gender为???,update person set gender=replace(gender,'man','???') where id=2333;
0x05 删除数据
删除id为2的数据,delete from `person` where id=2;
0x06 查找数据
查找后2行数据,select * from `person` limit 1,2;
按照name升序展示,select * from `person` order by name asc;
按照name降序显示,select * from `person` order by name desc;
条件查询,select * from `person` where name = 'Sun' ;