create database [数据库名称]; 创建数据库;
drop {database} [数据库名称]; 删除数据库;
create table aaa 创建表;
(
id varchar(88),
name varchar(66),
age varchar(22)
);
truncate table (); 删除表所有数据
describe [表名称]; 查看表结构;
alter table [表名称] engine=[引擎名] 更改表的储存引擎;
drop table [表名称]; 删除没有任何关联的单独表;
如果提示没有删除说明此表有外键约束,需要先删除外键约束。insert into [表名称] (列名1,列名2..........)
values[值1,值2................]; 插入语句
update [表名称]
set 字段名1=修改后的值1[字段名2=修改后的值2...............] 修改字段值
alter table [旧表名] rename [新表名]; 修改表名
alter table [表名] drop [字段]; 删除表里的字段
alter table [表名] add [字段] [数据类型]; 添加表里的字段
alter table [表名] change [旧字段] [新字段] [数据类型] ; 删除表里的字段
#找出10部门经理、20部门员工的职员的员工信息
select * from emp where job="manager" and deptno=10 or job!="manager" and deptno=20;
#找出姓名以A、B、S开始的员工信息
select * from emp where ename like "a%" or ename like "b%" or ename like "s%";
#找出奖金少于100或者没有获得奖金的员工的信息
select * from emp where comm<100 or comm is null;
#名字中不包含R字符的员工信息
select * from emp where ename not like "%r";
#返回员工的信息并按照工作降序工资升序排列
select * from emp order by job desc,sal asc;
#找出姓名中包含A的员工信息
select * from emp where ename like "%a%";