- 表
1.创建表
create table 表名
( 指标1 指标类型,
指标2 指标类型,
....);
2.删除表
drop table 表名
3.查看表结构
desc 表名;
4.修改表名
方式1:alter table 表名
rename to 新表名
方式2:rename 表名 to 新表名;
5.添加/删除/修改指标
alter table 表名
添加:add 指标名 指标类型 ;
eg:add p_n varchar(20)
删除:drop 指标名;
eg:drop p_n
修改:modify 指标名 指标类型;
eg:modify time datetime;
6.添加行
insert into 表名
values (变量值11,变量值21 ,变量值31,....);
(变量值21,变量值22 ,变量值23 ,....);
(变量值n1...,变量值n2...,变量值n3...,...);
7.连接
inner/left/right join
select 指标名
from 表1
inner/left/right/full 表2
on 表1.指标名1=表2.指标名2
8.筛选
select 指标名
from 表名
where 指标名 运算符 “ 变量值”
运算符有
= 等于 <>不等于 >大于 <小于>=大于等于 <=小于等于 between在某个范围内 like搜索某种模式 in在集合内
and 并且 or 或者
9.排序
select 指标1 指标2
from 表名
oder by 指标1,指标2 desc
不标注升降序就默认为升序
10.修改行数据
update 表名
set 指标1=‘新变量值’,指标2=‘新变量值’
where 指标1=‘某一值’
加where是指修改特定的指标下对应的变量值 不加的话就会导致所有的指标1/2都修改为新变量值