--- http://www.itbegin.com/app/study/self/unifiedselfstudy/10020001 --删除表hr.dept --http://zhidao.baidu.com/question/743877745919926572.html DROP TABLE hr.dept; --创建表hr.dept CREATE TABLE hr.dept ( deptno NUMBER(2), name CHAR(4), english int(10), chinesh int(10), math int(10), cno char(4) ); show columns from hr.dept; insert into hr.dept(deptno,name,english,chinesh,math,cno) values (1,'wz',10,20,30,'y'); insert into hr.dept(deptno,name,english,chinesh,math,cno) values (2,'wz1',10,90,30,'d'); insert into hr.dept(deptno,name,english,chinesh,math,cno) values (3,'wz2',10,90,90,'l'); insert into hr.dept(deptno,name) values (4,'wz4' ); insert into hr.dept(deptno,name,english,chinesh,math,cno) values (5,'wzx',99,20,66,'y'); insert into hr.dept(deptno,name,english,chinesh,math,cno) values (6,'wz1x',44,70,30,'d'); insert into hr.dept(deptno,name,english,chinesh,math,cno) values (7,'wz2x',66,88,55,'l'); -- 找到没有成绩的人--- /**** select deptno,name,english,chinesh,math from hr.dept where math is NULL *** select deptno,name,math from hr.dept where math is not NULL *** select deptno,name,math from hr.dept where deptno>1 order by math desc --asc 在线查找输出仅可以一条 ** select count(*) from hr.dept ** select deptno,name,math from hr.dept order by math --默认升序 ** -- select deptno,name,math from hr.dept where name LINK'_x%';--link '_x%'; --select max(math) --from hr.dept --各课程号所对应人数 select cno,count(cno) from hr.dept group by cno **/ /***** ---循环添加记录 --- --DECLARE @i int --DECLARE @name char(4) --开始 循环 插入数据-- --Set @i = 6 --WHILE @i < 10 --BEGIN --Set @i =@i +1 --SET @name = RIGHT('00000' + CAST(@i AS varchar(10)),5) --insert into hr.dept values(@i)--,@name,@i,@i,@i) --END ***********/