- 浏览: 251085 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (221)
- A序 (4)
- 系统学习(读书笔记) (5)
- Computer-base (14)
- RFC-协议规范 (9)
- OS-windows (3)
- OS-linux (10)
- 项目管理-需求设计 (2)
- 设计模式 (1)
- Java-基础-抽象规范 (15)
- Java-基础-core-code (15)
- Java-Thread (15)
- JAVA-stream 流 (1)
- JAVA-socket (13)
- JAVA-SSL (5)
- JAVA-RMI-JMX-OSGI (7)
- java-web (6)
- 工具 (19)
- W3C (16)
- DB (12)
- 读书笔记 (5)
- 中间件 (1)
- C/C++ (1)
- JAVA-JAXB (3)
- Java-UI (1)
- JAVA命令 (1)
- JVM实战 (1)
- java-base (3)
- maven (1)
最新评论
-
Nabulio:
厉害
tomcat 源码学习 -
zbz:
例子很简单,可是怎么设置访问账号和密码呢?注释掉的那段不起作用 ...
jmx 实例--最简单的例子 -
zk302:
格式可以优化下
sql-经典例子练习 -
tuspark:
eclipse的访问控制图标,可以看这篇《eclipse的访问 ...
Eclipse(四)常用设置 -
xlshl43:
流比呀。。。但这排版看的有点蛋疼。。。
Java核心代码(二)Class loader
/************************************************************************************************************
* 数据见50条常用sql.sql脚本
* 1.学生表
* student(studentID,stu_name,stu_age,stu_sex) --studentID 学生编号,stu_name 学生姓名,stu_age 出生年月,stu_sex 学生性别
* 2.课程表
* course(courseID,crs_name,teacherID) --courseID --课程编号,crs_name 课程名称,teacherID 教师编号
* 3.教师表
* teacher(teacherID,tea_name) --teacherID 教师编号,tea_name 教师姓名
* 4.成绩表
* stu_crs(studentID,courseID,score) --studentID 学生编号,courseID 课程编号,score 分数
////"01"课程、"02"课程是变量(记录)。不是常量(字段)。
////如果把"01"、"02"设计成字段,就会使难度降低,但是不够灵活。比如以后会再加一科目04物理。
* ########方法:先确定哪些表的字段,再一一满足条件,即可。
************************************************************************************************************/
表达式:where isnull(b.score,0)是简单的动态,还有动态sql。
连接顺序:选择那个表作为源数据表,那个表优先被连接
3、group by子句将数据划分为多个分组;
5、使用having子句筛选分组;
7、使用order by对结果集进行排序。
group by 、左外连接和where并用。
--1、查询"01"课程比"02"课程成绩高的学生的信息及课程分数
#####同一个表同一个字段值的比较,把一个表变为两个表,才能比较。
#####正常的是,一个字段值和一个常量比较。
有两种情况:1.1、1.2
--1.1、同时存在"01"课程和"02"课程的情况(01必选课,02必选课)
SELECT a.*,b.score,c.score
FROM student a,stu_crs b,stu_crs c
WHERE b.courseID='01' AND c.courseID='02' AND b.score>c.score AND a.studentID=b.studentID AND c.studentID=a.studentID
(a.studentID=b.studentID AND c.studentID=a.studentID这两个都需要,因为c.studentID和b.studentID与a表关联的结果集不一样)
--1.2、存在"01"课程但可能不存在"02"课程的情况、(01必选课,02选修课)、(不存在时显示为null)(以下存在相同内容时不再解释)
select * from student a
left join stu_crs b on a.studentID=b.studentID and b.courseID='01'
left join stu_crs c on a.studentID=c.studentID and c.courseID='04'
and b.score>c.score (and 有8条,where b.score>c.score只有一条)
--3、查询平均成绩大于等于60分的同学的学生编号和学生姓名和平均成绩
select a.*,avg(b.score) from student a,stu_crs b
where a.studentID = b.studentID
group by a.studentID
having avg(b.score)>70
order by avg(b.score) desc
--5、查询所有同学的学生编号、学生姓名、选课总数、所有课程的总成绩
--5.1、查询所有有成绩的SQL。
select a.*,count(b.score),sum(b.score) from student a,stu_crs b
where a.studentID = b.studentID #######因为“表达式需要b.score”,且b.score可能有空的。resultSet7条。
group by a.studentID
--5.2、查询所有(包括有成绩和无成绩)的SQL。
select a.*,count(b.score),sum(b.score) from student a
left join stu_crs b on a.studentID = b.studentID #######left join,因为b.score可能有空的。resultSet8条。
group by a.studentID #######对结果集还要进行计算的,一般需要group by、having
--11、查询没有学全所有课程的同学的信息
select * from student a,stu_crs b,course c
where a.studentID=b.studentID
group by a.studentID
having count(distinct b.courseID) ######不能是count(distinct b.courseID)==1,因为group by a.studentID过了,
< count(distinct c.courseID)
--12、查询至少有一门课与学号为"01"的同学所学相同的同学的信息
select distinct ########distinct过滤重复结果
a.* from student a, stu_crs b where a.studentID = b.studentID and b.courseID
in (select courseID from stu_crs where studentID = '01') and a.studentID <> '01'
--13、查询和"01"号的同学学习的课程完全相同的其他同学的信息
select student.* from student where studentID in
(select distinct stu_crs.studentID from stu_crs where studentID <> '01'
and stu_crs.courseID in (select distinct courseID from stu_crs where studentID = '01') ######限定范围和限定数量一块就可以确定完全一样了。
group by stu_crs.studentID having count(1) = (select count(1) from stu_crs where studentID='01')) ###限定数量,count(1) 与count(*)效果一样。
--15、查询两门及其以上不及格课程的同学的学号,姓名及其平均成绩
select a.*,avg(b.score) from student a,stu_crs b
where a.studentID=b.studentID and a.studentID
in(select studentID from stu_crs where score <60 group by studentID having count(1)>1)
group by a.studentID
--------------------------------未完成--------------------------------
--17、按平均成绩从高到低显示所有学生的所有课程的成绩以及平均成绩
select a.studentID , a.stu_name ,avg(b.score) ps
max(case c.crs_name when N'语文' then b.score else null end) [语文], #####表达式???????????
from student a
left join stu_crs b on a.studentID = b.studentID
left join course c on b.courseID = c.courseID
group by a.studentID , a.stu_name
order by ps desc #####order by时可以用别名,不用再查一次了。
--21、查询不同老师所教不同课程平均分从高到低显示
select m.teacherID , m.tea_name , cast(avg(o.score) as decimal(18,2)) avg_score
from teacher m , course n , stu_crs o
where m.teacherID = n.teacherID and n.courseID = o.courseID
group by m.teacherID , m.tea_name
order by avg_score destu_crs
--22、查询所有课程的成绩第2名到第3名的学生信息及该课程成绩
--22.1 sql 2000用子查询完成
--score重复时保留名次空缺
select * from (select t.* , px = (select count(1) from stu_crs where courseID = t.courseID and score > t.score) + 1 from stu_crs t) m where px between 2 and 3 order by m.courseID , m.px
--score重复时合并名次
select * from (select t.* , px = (select count(distinct score) from stu_crs where courseID = t.courseID and score >= t.score) from stu_crs t) m where px between 2 and 3 order by m.courseID , m.px
--22.2 sql 2005用rank,DENSE_RANK完成
--score重复时保留名次空缺(rank完成)
select * from (select t.* , px = rank() over(partition by courseID order by score destu_crs) from stu_crs t) m where px between 2 and 3 order by m.courseID , m.px
--score重复时合并名次(DENSE_RANK完成)
select * from (select t.* , px = DENSE_RANK() over(partition by courseID order by score destu_crs) from stu_crs t) m where px between 2 and 3 order by m.courseID , m.px
--23、统计各科成绩各分数段人数:课程编号,课程名称,[100-85],[85-70],[70-60],[0-60]及所占百分比
--23.1 统计各科成绩各分数段人数:课程编号,课程名称,[100-85],[85-70],[70-60],[0-60]
--横向显示
select course.courseID [课程编号] , crs_name as [课程名称] ,
sum(case when score >= 85 then 1 else 0 end) [85-100],
sum(case when score >= 70 and score < 85 then 1 else 0 end) [70-85],
sum(case when score >= 60 and score < 70 then 1 else 0 end) [60-70],
sum(case when score < 60 then 1 else 0 end) [0-60]
from stu_crs , course
where stu_crs.courseID = course.courseID
group by course.courseID , course.crs_name
order by course.courseID
--纵向显示1(显示存在的分数段)
select m.courseID [课程编号] , m.crs_name [课程名称] , 分数段 = (
case when n.score >= 85 then '85-100'
when n.score >= 70 and n.score < 85 then '70-85'
when n.score >= 60 and n.score < 70 then '60-70'
else '0-60'
end) ,
count(1) 数量
from course m , stu_crs n
where m.courseID = n.courseID
group by m.courseID , m.crs_name , (
case when n.score >= 85 then '85-100'
when n.score >= 70 and n.score < 85 then '70-85'
when n.score >= 60 and n.score < 70 then '60-70'
else '0-60'
end)
order by m.courseID , m.crs_name , 分数段
--纵向显示2(显示存在的分数段,不存在的分数段用0显示)
select m.courseID [课程编号] , m.crs_name [课程名称] , 分数段 = (
case when n.score >= 85 then '85-100'
when n.score >= 70 and n.score < 85 then '70-85'
when n.score >= 60 and n.score < 70 then '60-70'
else '0-60'
end) ,
count(1) 数量
from course m , stu_crs n
where m.courseID = n.courseID
group by all m.courseID , m.crs_name , (
case when n.score >= 85 then '85-100'
when n.score >= 70 and n.score < 85 then '70-85'
when n.score >= 60 and n.score < 70 then '60-70'
else '0-60'
end)
order by m.courseID , m.crs_name , 分数段
--23.2 统计各科成绩各分数段人数:课程编号,课程名称,[100-85],[85-70],[70-60],[<60]及所占百分比
--横向显示
select m.courseID 课程编号, m.crs_name 课程名称,
(select count(1) from stu_crs where courseID = m.courseID and score < 60) [0-60],
cast((select count(1) from stu_crs where courseID = m.courseID and score < 60)*100.0 / (select count(1) from stu_crs where courseID = m.courseID) as decimal(18,2)) [百分比(%)],
(select count(1) from stu_crs where courseID = m.courseID and score >= 60 and score < 70) [60-70],
cast((select count(1) from stu_crs where courseID = m.courseID and score >= 60 and score < 70)*100.0 / (select count(1) from stu_crs where courseID = m.courseID) as decimal(18,2)) [百分比(%)],
(select count(1) from stu_crs where courseID = m.courseID and score >= 70 and score < 85) [70-85],
cast((select count(1) from stu_crs where courseID = m.courseID and score >= 70 and score < 85)*100.0 / (select count(1) from stu_crs where courseID = m.courseID) as decimal(18,2)) [百分比(%)],
(select count(1) from stu_crs where courseID = m.courseID and score >= 85) [85-100],
cast((select count(1) from stu_crs where courseID = m.courseID and score >= 85)*100.0 / (select count(1) from stu_crs where courseID = m.courseID) as decimal(18,2)) [百分比(%)]
from course m
order by m.courseID
--纵向显示1(显示存在的分数段)
select m.courseID [课程编号] , m.crs_name [课程名称] , 分数段 = (
case when n.score >= 85 then '85-100'
when n.score >= 70 and n.score < 85 then '70-85'
when n.score >= 60 and n.score < 70 then '60-70'
else '0-60'
end) ,
count(1) 数量 ,
cast(count(1) * 100.0 / (select count(1) from stu_crs where courseID = m.courseID) as decimal(18,2)) [百分比(%)]
from course m , stu_crs n
where m.courseID = n.courseID
group by m.courseID , m.crs_name , (
case when n.score >= 85 then '85-100'
when n.score >= 70 and n.score < 85 then '70-85'
when n.score >= 60 and n.score < 70 then '60-70'
else '0-60'
end)
order by m.courseID , m.crs_name , 分数段
--纵向显示2(显示存在的分数段,不存在的分数段用0显示)
select m.courseID [课程编号] , m.crs_name [课程名称] , 分数段 = (
case when n.score >= 85 then '85-100'
when n.score >= 70 and n.score < 85 then '70-85'
when n.score >= 60 and n.score < 70 then '60-70'
else '0-60'
end) ,
count(1) 数量 ,
cast(count(1) * 100.0 / (select count(1) from stu_crs where courseID = m.courseID) as decimal(18,2)) [百分比(%)]
from course m , stu_crs n
where m.courseID = n.courseID
group by all m.courseID , m.crs_name , (
case when n.score >= 85 then '85-100'
when n.score >= 70 and n.score < 85 then '70-85'
when n.score >= 60 and n.score < 70 then '60-70'
else '0-60'
end)
order by m.courseID , m.crs_name , 分数段
--24、查询学生平均成绩及其名次
--24.1 查询学生的平均成绩并进行排名,sql 2000用子查询完成,分平均成绩重复时保留名次空缺和不保留名次空缺两种。
select t1.* , px = (select count(1) from
(
select m.studentID [学生编号] ,
m.stu_name [学生姓名] ,
isnull(cast(avg(score) as decimal(18,2)),0) [平均成绩]
from student m left join stu_crs n on m.studentID = n.studentID
group by m.studentID , m.stu_name
) t2 where 平均成绩 > t1.平均成绩) + 1 from
(
select m.studentID [学生编号] ,
m.stu_name [学生姓名] ,
isnull(cast(avg(score) as decimal(18,2)),0) [平均成绩]
from student m left join stu_crs n on m.studentID = n.studentID
group by m.studentID , m.stu_name
) t1
order by px
select t1.* , px = (select count(distinct 平均成绩) from
(
select m.studentID [学生编号] ,
m.stu_name [学生姓名] ,
isnull(cast(avg(score) as decimal(18,2)),0) [平均成绩]
from student m left join stu_crs n on m.studentID = n.studentID
group by m.studentID , m.stu_name
) t2 where 平均成绩 >= t1.平均成绩) from
(
select m.studentID [学生编号] ,
m.stu_name [学生姓名] ,
isnull(cast(avg(score) as decimal(18,2)),0) [平均成绩]
from student m left join stu_crs n on m.studentID = n.studentID
group by m.studentID , m.stu_name
) t1
order by px
--24.2 查询学生的平均成绩并进行排名,sql 2005用rank,DENSE_RANK完成,分平均成绩重复时保留名次空缺和不保留名次空缺两种。
select t.* , px = rank() over(order by [平均成绩] destu_crs) from
(
select m.studentID [学生编号] ,
m.stu_name [学生姓名] ,
isnull(cast(avg(score) as decimal(18,2)),0) [平均成绩]
from student m left join stu_crs n on m.studentID = n.studentID
group by m.studentID , m.stu_name
) t
order by px
select t.* , px = DENSE_RANK() over(order by [平均成绩] destu_crs) from
(
select m.studentID [学生编号] ,
m.stu_name [学生姓名] ,
isnull(cast(avg(score) as decimal(18,2)),0) [平均成绩]
from student m left join stu_crs n on m.studentID = n.studentID
group by m.studentID , m.stu_name
) t
order by px
--25、查询各科成绩前三名的记录
--25.1 分数重复时保留名次空缺
select m.* , n.courseID , n.score from student m, stu_crs n where m.studentID = n.studentID and n.score in
(select top 3 score from stu_crs where courseID = n.courseID order by score destu_crs) order by n.courseID , n.score destu_crs
--25.2 分数重复时不保留名次空缺,合并名次
--sql 2000用子查询实现
select * from (select t.* , px = (select count(distinct score) from stu_crs where courseID = t.courseID and score >= t.score) from stu_crs t) m where px between 1 and 3 order by m.courseID , m.px
--sql 2005用DENSE_RANK实现
select * from (select t.* , px = DENSE_RANK() over(partition by courseID order by score destu_crs) from stu_crs t) m where px between 1 and 3 order by m.courseID , m.px
--26、查询每门课程被选修的学生数
select courseID , count(studentID)[学生数] from stu_crs group by courseID
--27、查询出只有两门课程的全部学生的学号和姓名
select student.studentID , student.stu_name
from student , stu_crs
where student.studentID = stu_crs.studentID
group by student.studentID , student.stu_name
having count(stu_crs.courseID) = 2
order by student.studentID
--28、查询男生、女生人数
select count(stu_sex) as 男生人数 from student where stu_sex = N'男'
select count(stu_sex) as 女生人数 from student where stu_sex = N'女'
select sum(case when stu_sex = N'男' then 1 else 0 end) [男生人数],sum(case when stu_sex = N'女' then 1 else 0 end) [女生人数] from student
select case when stu_sex = N'男' then N'男生人数' else N'女生人数' end [男女情况] , count(1) [人数] from student group by case when stu_sex = N'男' then N'男生人数' else N'女生人数' end
--29、查询名字中含有"风"字的学生信息
select * from student where stu_name like N'%风%'
select * from student where charindex(N'风' , stu_name) > 0
--30、查询同名同性学生名单,并统计同名人数
select stu_name [学生姓名], count(*) [人数] from student group by stu_name having count(*) > 1
--31、查询1990年出生的学生名单(注:student表中stu_age列的类型是datetime)
select * from student where year(stu_age) = 1990
select * from student where datediff(yy,stu_age,'1990-01-01') = 0
select * from student where datepart(yy,stu_age) = 1990
select * from student where convert(varchar(4),stu_age,120) = '1990'
--32、查询每门课程的平均成绩,结果按平均成绩降序排列,平均成绩相同时,按课程编号升序排列
select m.courseID , m.crs_name , cast(avg(n.score) as decimal(18,2)) avg_score
from course m, stu_crs n
where m.courseID = n.courseID
group by m.courseID , m.crs_name
order by avg_score destu_crs, m.courseID astu_crs
--33、查询平均成绩大于等于85的所有学生的学号、姓名和平均成绩
select a.studentID , a.stu_name , cast(avg(b.score) as decimal(18,2)) avg_score
from student a , stu_crs b
where a.studentID = b.studentID
group by a.studentID , a.stu_name
having cast(avg(b.score) as decimal(18,2)) >= 85
order by a.studentID
--34、查询课程名称为"数学",且分数低于60的学生姓名和分数
select stu_name , score
from student , stu_crs , course
where stu_crs.studentID = student.studentID and stu_crs.courseID = course.courseID and course.crs_name = N'数学' and score < 60
--35、查询所有学生的课程及分数情况;
select student.* , course.crs_name , stu_crs.courseID , stu_crs.score
from student, stu_crs , course
where student.studentID = stu_crs.studentID and stu_crs.courseID = course.courseID
order by student.studentID , stu_crs.courseID
--36、查询任何一门课程成绩在70分以上的姓名、课程名称和分数;
select student.* , course.crs_name , stu_crs.courseID , stu_crs.score
from student, stu_crs , course
where student.studentID = stu_crs.studentID and stu_crs.courseID = course.courseID and stu_crs.score >= 70
order by student.studentID , stu_crs.courseID
--37、查询不及格的课程
select student.* , course.crs_name , stu_crs.courseID , stu_crs.score
from student, stu_crs , course
where student.studentID = stu_crs.studentID and stu_crs.courseID = course.courseID and stu_crs.score < 60
order by student.studentID , stu_crs.courseID
--38、查询课程编号为01且课程成绩在80分以上的学生的学号和姓名;
select student.* , course.crs_name , stu_crs.courseID , stu_crs.score
from student, stu_crs , course
where student.studentID = stu_crs.studentID and stu_crs.courseID = course.courseID and stu_crs.courseID = '01' and stu_crs.score >= 80
order by student.studentID , stu_crs.courseID
--39、求每门课程的学生人数
select course.courseID , course.crs_name , count(*) [学生人数]
from course , stu_crs
where course.courseID = stu_crs.courseID
group by course.courseID , course.crs_name
order by course.courseID , course.crs_name
--40、查询选修"张三"老师所授课程的学生中,成绩最高的学生信息及其成绩
--40.1 当最高分只有一个时
select top 1 student.* , course.crs_name , stu_crs.courseID , stu_crs.score
from student, stu_crs , course , teacher
where student.studentID = stu_crs.studentID and stu_crs.courseID = course.courseID and course.teacherID = teacher.teacherID and teacher.tea_name = N'张三'
order by stu_crs.score destu_crs
--40.2 当最高分出现多个时
select student.* , course.crs_name , stu_crs.courseID , stu_crs.score
from student, stu_crs , course , teacher
where student.studentID = stu_crs.studentID and stu_crs.courseID = course.courseID and course.teacherID = teacher.teacherID and teacher.tea_name = N'张三' and
stu_crs.score = (select max(stu_crs.score) from stu_crs , course , teacher where stu_crs.courseID = course.courseID and course.teacherID = teacher.teacherID and teacher.tea_name = N'张三')
--41、查询不同课程成绩相同的学生的学生编号、课程编号、学生成绩
--方法1
select m.* from stu_crs m ,(select courseID , score from stu_crs group by courseID , score having count(1) > 1) n
where m.courseID= n.courseID and m.score = n.score order by m.courseID , m.score , m.studentID
--方法2
select m.* from stu_crs m where exists (select 1 from (select courseID , score from stu_crs group by courseID , score having count(1) > 1) n
where m.courseID= n.courseID and m.score = n.score) order by m.courseID , m.score , m.studentID
--42、查询每门功成绩最好的前两名
select t.* from stu_crs t where score in (select top 2 score from stu_crs where courseID = T.courseID order by score destu_crs) order by t.courseID , t.score destu_crs
--43、统计每门课程的学生选修人数(超过5人的课程才统计)。要求输出课程号和选修人数,查询结果按人数降序排列,若人数相同,按课程号升序排列
select course.courseID , course.crs_name , count(*) [学生人数]
from course , stu_crs
where course.courseID = stu_crs.courseID
group by course.courseID , course.crs_name
having count(*) >= 5
order by [学生人数] destu_crs , course.courseID
--44、检索至少选修两门课程的学生学号
select student.studentID , student.stu_name
from student , stu_crs
where student.studentID = stu_crs.studentID
group by student.studentID , student.stu_name
having count(1) >= 2
order by student.studentID
--45、查询选修了全部课程的学生信息
--方法1 根据数量来完成
select student.* from student where studentID in
(select studentID from stu_crs group by studentID having count(1) = (select count(1) from course))
--方法2 使用双重否定来完成
select t.* from student t where t.studentID not in
(
select distinct m.studentID from
(
select studentID , courseID from student , course
) m where not exists (select 1 from stu_crs n where n.studentID = m.studentID and n.courseID = m.courseID)
)
--方法3 使用双重否定来完成
select t.* from student t where not exists(select 1 from
(
select distinct m.studentID from
(
select studentID , courseID from student , course
) m where not exists (select 1 from stu_crs n where n.studentID = m.studentID and n.courseID = m.courseID)
) k where k.studentID = t.studentID
)
--46、查询各学生的年龄
--46.1 只按照年份来算
select * , datediff(yy , stu_age , getdate()) [年龄] from student
--46.2 按照出生日期来算,当前月日 < 出生年月的月日则,年龄减一
select * , case when right(convert(varchar(10),getdate(),120),5) < right(convert(varchar(10),stu_age,120),5) then datediff(yy , stu_age , getdate()) - 1 else datediff(yy , stu_age , getdate()) end [年龄] from student
--47、查询本周过生日的学生
select * from student where datediff(week,datename(yy,getdate()) + right(convert(varchar(10),stu_age,120),6),getdate()) = 0
--48、查询下周过生日的学生
select * from student where datediff(week,datename(yy,getdate()) + right(convert(varchar(10),stu_age,120),6),getdate()) = -1
--49、查询本月过生日的学生
select * from student where datediff(mm,datename(yy,getdate()) + right(convert(varchar(10),stu_age,120),6),getdate()) = 0
--50、查询下月过生日的学生
select * from student where datediff(mm,datename(yy,getdate()) + right(convert(varchar(10),stu_age,120),6),getdate()) = -1
drop table student,course,teacher,stu_crs
发表评论
-
sql 总结
2015-12-03 17:28 3771,将查询结果作为临时表: select * from ( ... -
Reserved-7
2014-03-24 17:37 603ffff -
SQL事务锁
2014-03-24 17:35 831保持数据库的纯粹性:完整性约束实际用不到,存储过程也不用。 ... -
sql-语法
2012-11-08 09:04 933@@IDENTITY全局变量, ... -
sql-概述
2012-11-08 09:04 748SQL(Structure Query Language ... -
oracle-语句
2012-11-09 11:08 931执行脚本 SQL> @ d:\test. ... -
oracle-索引
2012-11-09 11:08 885索引,为了提高查询速率//作用类似“书的目录” 索引的 ... -
oracle-自身函数
2012-11-09 11:08 13522、字典________________________ ... -
oracle-理论
2012-11-09 11:07 894网状DB-->关系DB--> ... -
oracle-常用函数
2012-11-09 11:07 844dual表可以用了查询很多。 1.ascii(s ... -
mysql 模板
2012-11-08 09:05 12881、概论________________________ ...
相关推荐
《笨方法学SQL》是一本深受读者喜爱的SQL学习书籍,其主要目标是通过实践性的方法帮助初学者...实践是学习SQL的关键,这本书通过大量的例子和练习,鼓励读者动手操作,从而真正理解并掌握SQL这一强大的数据查询语言。
以下是一些关于PL/SQL的经典练习题及其涉及的知识点: 1. **声明变量和游标**: - 在PL/SQL中,`DECLARE`语句用于声明变量。例如,`v_emp emp%rowtype`声明了一个变量`v_emp`,它的类型与`emp`表中的行类型相同。 ...
在SQL Server 2012中,我们可以通过各种SQL语句来管理数据库中的数据,包括插入、更新、删除以及查询。以下是对给定文件中各部分的详细解释: 1. **插入数据**: - `INSERT INTO` 语句用于向表中添加新记录。在...
"经典SQL例子-scott"这个资源是学习SQL的一个宝贵资料,它包含了Oracle数据库中的经典实例。Oracle是全球广泛使用的数据库管理系统之一,其内置的"SCOTT"用户示例数据库提供了丰富的练习场景。 SCOTT是Oracle中的一...
《C#实例.net-经典例子400个》是一份包含丰富C#编程实践的资源,涵盖了.NET框架下的各种常见应用场景。这份文档包含了400个精心挑选的示例,旨在帮助开发者深入理解和掌握C#语言及.NET平台的核心概念和技术。 在C#...
在IT领域,SQL(Structured Query Language)是一种用于管理和处理关系型数据库的强大语言。...因此,"call-SQL-data-example.rar_sql"提供的资源对初学者或需要巩固基础的开发者来说,是一个宝贵的练习素材。
例子 package main import ( database/sql "github.com/go-sql-driver/mysql" # load driver before load go-sql-tracer _ "github.com/walf443/go-sql-tracer" ) func main() { db, err := sql.Open('mysql...
"sqlserver2008数据库实例练习-卡哥"是一个专为初学者设计的实例,它提供了学习和提升SQL技能的机会,特别是针对查询、更新、插入和删除等基本操作。这个练习实例是一个基于学生成绩管理系统的数据库,通过实际操作...
SQL(Structured Query Language)是一种...这个"sql学习经典"压缩包文件可能包含了大量关于这些主题的实际例子和练习,可以帮助你更好地理解和运用SQL基本语法。不断实践和探索,你将逐渐成长为一名熟练的SQL开发者。
根据给定的经典SQL练习题的信息,我们可以总结出以下几个重要的知识点: ### 1. SQL 表的创建 在SQL中,创建表是通过`CREATE TABLE`语句实现的。本练习题中涉及到了四个表的创建:`STUDENT`、`COURSE`、`SCORE` 和...
这样的练习能帮助学习者更好地理解和应用SQL语言,从而提高他们在数据库管理中的技能。 总之,"学生-课程-选课"是一个极好的学习资源,它不仅涵盖了数据库设计的基础知识,也提供了实践机会,让学习者能够亲手操作...
《PB精彩编程案例--经典的小例子》是一份专注于PowerBuilder编程实践的资源集合,它包含了大量精心设计的小型示例程序,旨在帮助开发者深入理解和掌握PowerBuilder 9.0版本的特性和功能。PowerBuilder是一种强大的...
### SQL语句强化练习知识点详解 #### 一、简单查询 **知识点1:查询所有学生信息** - **SQL语句**: `SELECT * FROM 学生;` - 这条语句用于查询`学生`表中的所有列和所有行。 **知识点2:查询特定条件下学生信息*...
在SQL(Structured Query Language)中,我们可以执行各种操作来管理和查询...以上就是针对给定SQL练习题目的详细解答,涵盖了查询、插入、更新和删除等基本操作。这些例子展示了如何在不同的场景下使用SQL来处理数据。
标题“sql-portfolio:SQL任务组合”表明这是一个包含多种SQL相关练习或项目集合的资源,可能用于学习、自我提升或兴趣爱好。SQL是Structured Query Language的缩写,是用于管理和处理关系数据库的标准语言。这个...
在SQL(Structured Query Language)的学习过程中,练习题是提升技能的关键环节。"典型Sql练习题"这个主题涵盖了从基础查询到复杂联接、子查询、存储过程等多个方面,旨在帮助C#、ASP.NET开发者以及数据库管理员...
在这个"sql练习语句,培训用,比较典型的例子好用"的资源中,我们可以期待学习到一系列SQL的基础与进阶用法,适用于SQL初学者或希望提升技能的人员。 首先,让我们从基础开始。SQL主要包括以下几个基本操作: 1. *...
示例包括:表内容查询、表的结构查询、函数转换、SQL简单语句练习、各种复杂查询以及Oracle listener错误解决方法等等。