数据库的命令:
查看所有数据库:show databases;
查看当前使用的数据库:select databases();
切换数据库:use 数据库名;
创建数据库:create database 数据库名 charser=utf8;
删除数据库:drop databases 数据库名;
数据库表的命令:
查看所有表:show tables;
创建表:create table 表名(id int auto_increment primary key not null,...);
删除表:drop table 表名;
修改表:alter table 表名 add|change|drop 列;
数据库的命令crud:
查询:select * from 表名;
增加:insert into 表名 values(...);
修改:update 表名 set 字段=值...
删除:delete from 表名
逻辑删除:本质就是修改
逻辑运算符:
and
or
not
查询编号大于3的女生
select * from students where id>3 and gender=0;
查询编号小于4或没被删除的学生
select * from students where id<4 or isdelete=0;
模糊查询:like
查询姓黄或叫靖的学生
select * from students where name like '黄%' or name like ‘%靖’;
范围查询:
查询编号是1或3或8的学生
select * from students where id in(1,3,8);
查询学生是3至8的男生
select * from students where id between 3 and 8 and gender=1;
空判断、
查询生日为空的学生
select * from students where birthday is null;
查询生日不为空的学生:select * from students where birthday is not null;