创建、删除 数据库create database mydatadrop database mydata创建、删除 表careate table mytable
(id int(4) not null,name varchar(10) not null,age int(4),sex int(4) not null
Constrain primaty key pk_mytable(id) );drop table my插入数据
insert into mytable(id, name,sex,age) 
values('001','hhh','1','20')insert into mytable values('001','hhh','20','1')insert into newmytable(id,name)
select id,name
from mytable
whrer name='hhh'在表中删除数据
delete from mytable where id='003' and age='20';更新表中数据
updata mytable set name=h01 where id=001; //id为001的名字给为h01查询数据
//select 显示内容的条件 from 表名 where 满足条件
select * from mytable where age=20 and name='hhh'存储过程
create proc条件子句
where
where后 列的数据类型为数字型,不需要用引号,如列数据类型为字符型要用单引号
in not in
in选择列值与值列表中某一个值相等的相关信息,not in选择那些不在列表中的记录
between ... and not between ... and
选择列值在某个范围内的记录,not between ... and选择那些不在该范围的记录
like not like
用于查找字符传的匹配。“%”任意长度,“_”一个字符
is null is not null
查找列值为空值后非空值的记录
and or
“与”要同时满足多个条件,“或”满足一个条件就可以
order by
显示排列数据,默认(ASC)升序,加(DESC)降序索引
创建、删除 视图
//cresate view myviewdrop view myview更改表的结构
——添加、删除一个字段
alter tabel mytable add sex bit
alter table mytable drop column age
——添加、删除约束语句
alter table mytable add constraint pk_id check(id!='test')
alter table mytable drop constraint pk_id