Mysql进入与退出
进入数据库:mysql -uroot -p
退出: exit
库级操作语句
表级操作语句
MysSQL表中数据的操作
插入数据(create) insert into values
查询数据 (read) select from where
例:select name from student where age = 19;
(查询学生表里年龄等于19的姓名)
select * from 表名 where 表头字段 条件;
例:select * from student where age = 19;
(查询学生表里等于19岁的全部字段)
修改数据(update)update set where
例:update student set id = 5 where name =某某;
(把学生表姓名为某某的id改成5)
删除数据 (delete)delete from where
例:delete from student where name = 某某;
(删除学生表里某某整行值)
MySQL数据类型:
数值类型、字符类型、时间日期类型
数值类型常用举例
字符类型常见举例
时间日期类型
案例
MySQL筛选条件
In null 例子
select * from student where id is null;
错误例子: select * from student where is = null;(这样是显示不了的,空值以这种方式查询是查不出来的)
in not null 例子
select * from student where id is not null;
与或非
and or not
and 例子:select * from student where id =5 and age = 9;
排序(order by)
正序举例:select * from student order by age;
倒序举例:select * from student order by age desc;
限制(limit)
举例:select * from student limit 0,5;
(MySQL是 左闭右闭)
去重(distinct)
举例:select distinct * from student;
原文:https://www.cnblogs.com/gd000-/p/10651839.html