人人范文网 范文大全

vfp第六章SQL命令

发布时间:2020-03-01 18:51:48 来源:范文大全 收藏本文 下载本文 手机版

数据定义

create table d:\\人事管理人事档案 free (编号 c(7),姓名 c(8),性别 c(2),; 基本工资 N(7,2), 出生年月 d null)

create table 学生1(学号 c(5) primary key,姓名 c(8),入学成绩 n(5,1) check(入学成绩>0) error \"成绩应该大于0!\")

create table 课程1(课程号 c(5) primary key,课程名 C(20),学分 N(1))

create table 选课2(学号 C(5),课程号 C(5),; 成绩 I check(成绩>=0 and 成绩

open database 学生管理费用

alter table 课程1 add 学时 I check(学时>16) error \"学时应该大于16\"

alter table 课程1 alter 学时 drop check

alter table 课程1 drop column 学时

数据查询

select * from 学生

select distinct 姓名 as 学生名单,year(date())-year(出生日期) as 年龄 from 学生

select 学号,姓名,round(入学成绩,0) as \"入学成绩\" from 学生

select avg(入学成绩) as \"入学成绩平均分\" from 学生

select * from 学生 where 入学成绩>560

select 籍贯,avg(入学成绩) as 入学成绩平均分 from 学生 where 籍贯=\"湖南\"

select 学号,姓名,籍贯 from 学生 where 籍贯\"湖南\" select 学号,姓名,籍贯 from 学生 where 籍贯!=\"湖南\"

select 学号,姓名,籍贯 from 学生 where not(籍贯=\"湖南\")

select 学号,姓名,籍贯 from 学生 where 籍贯 in (\"江苏\",\"贵州\")

select 学号,姓名,籍贯 from 学生 where 籍贯=\"江苏\" or 籍贯=\"贵州\"

select 学号,姓名,入学成绩 from 学生 where 入学成绩 between 560 and 650

select 学号,姓名,入学成绩 from 学生 where 入学成绩>=560 and 入学成绩

select 学号,姓名 from 学生 where 姓名 like \"赵%\"

select 学号,姓名 from 学生 where 姓名=\"赵\"

select 学号,姓名 from 学生 where at(\"赵\",姓名)=1

select 学号,姓名 from 学生 where left(姓名,2)=\"赵\"

select 学号,课程号 from 选课 where 成绩 is null 嵌套查询

select 学号 from 选课 where 课程号=; (select 课程号 from 课程 where 课程名=\"数据库原理\")

select 学号 from 选课 where 课程号=all; (select 课程号 from 课程 where 课程名=\"数据库原理\")

select 学号,成绩 from 选课 where 课程号=\"01101\" and 成绩>all; (select 成绩 from 选课 where 课程号=\"01102\")

select 学号 from 选课 where 课程号 in; (select 课程号 from 课程 where 课程名=\"数据库原理\" or 课程名=\"软件工程\")

select a.学号,姓名,b.课程号,课程名,成绩 from 学生 a,选课 b,课程 c; where a.学号=b.学号 and b.课程号=c.课程号

select a.学号,a.姓名 as 学生姓名,b.课程号,课程名,e.姓名 as 教师姓名,学分; from 学生 a,选课 b,课程 c,授课 d,教师 e; where a.学号=b.学号 and b.课程号=c.课程号 and c.课程号=d.课程号; and d.教师号=e.教师号 and 性别=\"男\" select a.学号 from 选课 a,选课 lk; where a.学号=b.学号 and b.课程号=\"01101\" and a.课程号=\"15104\" select a.学号 from 选课 a,选课 b; where a.学号=b.学号 and b.课程号=\"01101\" and a.课程号=\"01102\"

select a.学号,a.成绩 from 选课 a,选课 b; where a.成绩>b.成绩 and a.课程号=b.课程号 and ; b.课程号=\"01102\" and b.学号=\"200109\"

联接查询

select a.学号,b.课程号,成绩 from 学生 a,选课 b; where a.学号=b.学号 and 少数民族否

select a.学号,b.课程号,成绩 from 学生 a inner join 选课 b; on a.学号=b.学号 where 少数民族否

查询结果处理

select a.学号,姓名,b.课程号,课程名,成绩 from 学生 a,选课 b,课程 c; where a.学号=b.学号 and b.课程号=c.课程号; order by 性别,课程名,成绩 desc

select a.学号,姓名,b.课程号,课程名,成绩 from 学生 a,选课 b,课程 c; where a.学号=b.学号 and b.课程号=c.课程号; order by 性别,课程名,成绩 desc to file test1

select a.学号,姓名,b.课程号,课程名,成绩 from 学生 a,选课 b,课程 c; where a.学号=b.学号 into cursor test

select a.学号,姓名,b.课程号,b.课程名,成绩 from test a,课程 b; where a.课程号=b.课程号 into table testtable order by a.学号

select 学号 from 选课 where 课程号=\"01101\" union select 学号 from 选课 where 课程号=\"01102\" select 学号,课程号 from 选课 where 课程号=\"01101\" union select 学号,课程号 from 选课 where 课程号=\"01102\"

select 性别,count(性别) from 学生 group by 性别

select 性别,count(性别) from 学生 group by 性别 where 少数民族否 select 课程号,avg(成绩) from 选课 group by 课程号 having avg(成绩)>=80

数据操纵

insert into 学生 values(\"231002\",\"阳雨光\",\"男\",{^1988-09-10},.t.,\"上海\",610,\"\",\"\")

insert into 学生(学号,姓名) values(\"231109\",\"王大力\")

delete from 学生 where 性别=\"男\"

update 学生 set 籍贯=\"广东\" where 姓名=\"胡敏杰\"

update 选课 set 成绩=成绩+20; where 学号 in (select 学号 from 学生 where 性别=\"男\")

dimension a(5) a(1)=\"231013\" a(2)=\"张阳\" a(3)=\"女\" a(4)={^1988-09-10} a(5)=.t.insert into 学生 from array a

SQL命令题答案

SQL DBCC 命令 说明

vfp命令、语句等说明总结

VFP命令、函数及程序语句解读

VFP对口高考命令3至5

5、VFP数据库的操作及SQL语言的应用

经典MSSQL语句和常用SQL语句命令的作用

Acce课堂练习六SQL命令查询操作书面练习

vfp教学大纲

命令

vfp第六章SQL命令
《vfp第六章SQL命令.doc》
将本文的Word文档下载到电脑,方便编辑。
推荐度:
点击下载文档
点击下载本文文档