创建表
修改表结构
alter table www alter 编号 N(8) alter 姓名 c(8)
删除字段
alter table www drop 生日
增加字段
alter table www add 出生日期 D
更名字段
alter table rcda rename 照片 to 相片
删除表
drop table www
查询表所有内容
select * from 教师
查询教师表中3个字段“编号,姓名,性别”
select 编号,姓名,性别 from 教师
查询女教师
select 编号,姓名,性别 from 教师 where 性别="女"
查询女教师信息,并生成新表aaa
select 编号,姓名,性别;
from 教师 where 性别="女";
into table aaa
按性别分组查询表教师
sele * from 教师 group by 性别
按编号排序查询
select 编号,姓名,性别;
from 教师 where 性别="女" order by 编号
降序查询
select 编号,姓名,性别;
from 教师 where 性别="女" order by 编号 desc
查询条件组合
select * from 教师 where 年龄 >=20 and 年龄<=30
select * from 教师 where 年龄 between 20 and 30
多表查询:
sele 学生信息.学号,姓名,性别,语种;
from 学生信息,选课信息 where 学生信息.学号=选课信息.学号
sele xs.学号,姓名,性别,语种;
from 学生信息 as xs,选课信息 as xk where xs.学号=xk.学号
统计查询
sele avg(奖学金) as 女生平均奖学金 from 学生信息 where 性别="女"
sele sum(奖学金) as 女生奖学金 from 学生信息 where 性别="女"
sele count(*) from 教师 where 性别="女"
sele count(姓名) from 教师 where 性别="女"
sele count(姓名) as 女教师数量 from 教师 where 性别计算机二级查成绩="女"
嵌套查询
sele 学生信息.学号,学生信息.姓名,学生信息.性别,成绩信息.课程名,成绩信息.成绩;
from 学生信息 inner join 成绩信息 on 学生信息.学号=成绩信息.学号
sele 学生信息.学号,学生信息.姓名,学生信息.性别,成绩信息.课程名,成绩信息.成绩;
from 学生信息 inner join 成绩信息 on 学生信息.学号=成绩信息.学号;
where 学生信息.学号 in (select 学号 from 选课信息 where 语种="日语")
删除
delete from 学生信息 where 性别="女"
插入
insert into 学生信息(学号,姓名,性别,出生日期);
values("20090000","芙蓉","男",{^1950-01-02})
insert into 学生信息 values("99999999","999999","女",date(),"1010",t,999.99)
更新
update 学生信息 set 专业编号="9999" where 姓名="芙蓉"
发布评论