50道数据库SQL练习题(深入理解各关键字的作用)

目录

表结构

设有学生表(T_Student)、教师表(T_teacher)、课程表(T_Course)和成绩表(T_score)。
表结构及其关系如下UML图所示。
在这里插入图片描述

创建表

下面列出了Oracle数据库表的创建代码。我并没有设主键。

create table T_Student
(
      Student_ID int, 
      Student_name varchar2(32),
      Student_age int,
      Student_sex char(1)
);
//学生表由于涉及到个人信息,这里不做展示。请自行补全。
create table T_teacher
(
       t_id int,
       t_name varchar2(20)
);
insert into T_Teacher values(101,'葛老师');
insert into T_Teacher values(102,'五木老师');
insert into T_Teacher values(103,'华仔老师');
insert into T_Teacher values(104,'罗老师');
insert into T_Teacher values(105,'黄老师');
create table T_Course
(
     Course_ID int,
     Course_name varchar2(30), 
     T_ID int 
);
//某一个老师教的课程可以是多种的。
insert into T_Course values(101,'数据库',101);
insert into T_Course values(102,'QT',102);
insert into T_Course values(103,'C++',103);
insert into T_Course values(104,'C语言',104);
insert into T_Course values(105,'linux',105);

create table T_score
(
      Student_ID int,  
      Course_ID int,
      score number(5,2)
);
insert into T_score values(1,101,80);

insert into T_score values(9,101,76);
insert into T_score values(9,102,44);
insert into T_score values(9,104,83);
insert into T_score values(9,105,70);

insert into T_score values(11,101,83);
insert into T_score values(11,102,75);
insert into T_score values(11,103,98);
insert into T_score values(11,104,66);
insert into T_score values(11,105,83);

insert into T_score values(13,104,83);
insert into T_score values(13,105,91);

insert into T_score values(14,101,79);
insert into T_score values(14,102,100);
insert into T_score values(14,103,81);
insert into T_score values(14,104,77);

insert into T_score values(15,101,84);
insert into T_score values(15,103,88);
insert into T_score values(15,104,60);
insert into T_score values(15,105,70);
//只列出部分成绩表的数据 可自行补齐。

练习题

这里列出了大约50个SQL练习题,解法未考虑效率只是为了尽可能多的练习语法。下面解法为Oracle数据库语法格式。

1、查询“001”课程比“002”课程成绩高的所有学生的学号

--解法一
create or replace view v11 
as
select *
from T_score
where course_id = 101;

create or replace view v12 
as
select *
from T_score
where course_id = 102;

select a.student_id 学号
from v11 a, v12 b
where a.student_id = b.student_id and a.score > b.score; 
--解法二  
create or replace view v13
as
(select a.student_id,
       max(case when b.course_id = 101 then b.score else NULL end) aa,
       max(case when b.course_id = 102 then b.score else NULL end) bb
from T_student a, T_score b
where a.student_id = b.student_id 
group by a.student_id);       

select student_id 学号
from v13
where aa > bb;
--解法三
select a.student_id 学号
from t_score a, t_score b
where a.student_id = b.student_id and a.course_id = '101'
      and b.course_id = '102' and a.score > b.score;

2、查询所有同学的学号、姓名、选课数、总成绩

--解法一
select a.student_id 学号, 
       a.student_name 姓名, 
       count(nvl(b.course_id, 0)) 选课数, 
       sum(b.score) 总成绩
from T_student a, T_score b
where a.student_id = b.student_id
group by a.student_id, a.student_name;

3、查询平均成绩大于60分的同学的 学号和平均成绩

select student_id 学号,
       trunc(avg(score), 2) 平均成绩 
from T_score 
group by student_id
having avg(score) > 60;

4、查询姓“葛”的老师的个数

select count(1) 姓葛老师的人数
from T_teacher
where t_name like '葛%'; 

5、查询没学过“五木”老师课的同学的学号、姓名

--解法一
create or replace view v51
as
select b.course_id
from T_teacher a, T_course b
where a.t_id = b.t_id and a.t_name = '五木老师';

create or replace view v52
as
select a.student_id aa, 
       sum(case when b.course_id = c.course_id then 1 else 0 end) bb,
       a.student_name cc
from T_student a left join T_score b
                 on a.student_id = b.student_id ,v51 c
group by a.student_id, a.student_name;

select aa 学号, cc  姓名
from v52
where bb = 0;
--解法二
create or replace view v53
as
select c.student_id
from T_teacher a, T_course b, T_score c
where a.t_id = b.t_id and b.course_id = c.course_id and a.t_name = '五木老师';

select student_id 学号
from T_student a
where student_id not in (select student_id from v53)
--解法三
create or replace view v53
as
select c.student_id
from T_teacher a, T_course b, T_score c
where a.t_id = b.t_id and b.course_id = c.course_id and a.t_name = '五木老师';

select student_id 学号
from T_student a
where not exists (select 1 from v53 where v53.student_id = a.student_id)

6、查询学过“101”并且也学过编号“102”课程的同学的学号、姓名

--方法一
select a.student_id 学号, c.student_name 姓名
from (select * from T_score where course_id = 101) a,
     (select * from T_score where course_id = 102) b, 
     T_student c
where a.student_id = b.student_id and b.student_id = c.student_id;
--方法二
select a.student_id 学号, b.student_name 姓名
from (select student_id from T_score where course_id = 101
      intersect
      select student_id from T_score where course_id = 102)a, T_student b
where a.student_id = b.student_id

7、查询学过“五木”老师所教的所有课的同学的学号、姓名

--v52请见第五题第二种解法的视图
select aa 学号, cc  姓名
from v52
where bb = 1;

8、查询课程编号“102”的成绩比课程编号“101”课程低的所有同学的学号、姓名

select a.student_id 学号, c.student_name 姓名
from (select * from T_score where course_id = 101) a,
     (select * from T_score where course_id = 102) b, T_student c
where a.student_id = b.student_id and b.student_id = c.student_id and b.score < a.score

9、查询所有课程成绩小于60分的同学的学号、姓名

create or replace view v91
as
select student_id, 
       sum(case when score < 85 then 1 else 0 end) aa,
       count(1) bb
from T_score
group by student_id;

select b.student_id 学号,  b.student_name 姓名
from v91 a, T_student b
where a.student_id = b.student_id and a.aa = a.bb;

10、查询没有学全所有课的同学的学号、姓名

create or replace view v92
as
select student_id, count(1) aa
from T_score
group by student_id;

select b.student_id 学号,  b.student_name 姓名
from T_student b left join v92 a 
                 on a.student_id = b.student_id 
where nvl(a.aa, 0) != 5;

11、查询至少有一门课与学号为“1”的同学所学相同的同学的学号和姓名

create or replace view v112
as
select a.student_id
from T_score a
where a.student_id != 1 
      and a.course_id in (select course_id from T_score where student_id = 1)
group by a.student_id;

select distinct a.student_id 学号, b.student_name 姓名
from v112 a, T_student b
where a.student_id = b.student_id;

12、查询至少学过学号为“001”同学所有课的其他同学学号和姓名

create or replace view v121
as
select count(1) aa from T_score where student_id = 1;

create or replace view v122
as    select student_id aa, 
          sum(case when course_id in (select course_id
                                      from T_score
                                      where student_id = 1) then 1 else 0 end) bb
from T_score
where student_id != 1
group by student_id;

select a.aa
from v122 a, v121 b
where bb = b.aa;

13、把“成绩”表中“五木”老师教的课的成绩都更改为此课程的平均成绩

create or replace view v131
as  select course_id
    from T_teacher a, t_course b
    where a.t_id = b.t_id and t_name = '五木老师'; 

create or replace view v132
as  select avg(score) bb
    from T_score a, v131 b
    where a.course_id = b.course_id;

update T_score a 
set score = (select * from v132)
where (select course_id
      from T_teacher a, t_course b
      where a.t_id = b.t_id and t_name = '五木老师') = a.course_id;

select * from T_score
where course_id = 102;

14、查询和“1002”号的同学学习的课程完全相同的其他同学学号和姓名

create or replace view v141
as  select student_id, course_id, score
    from T_score
    where student_id = 2;

create or replace view v142  
as  select * 
    from T_score
    where student_id != 2;

create or replace view v143  
as 
select
      student_id,
      sum(case when a.course_id in (select course_id
                                    from v141) then 1 else -1 end) aa
from v142 a
group by student_id;

select a.student_id 学号, b.student_name 姓名
from v143 a, t_Student b
where a.student_id = b.student_id 
      and a.aa = (select count(1) aa from v141);

15、删除学习“五木”老师课的SC表记录

create or replace view v151
as  select b.course_id
    from T_teacher a, T_course b
    where a.t_id = b.t_id and a.t_name = '五木老师';

delete from T_score
where course_id in (select course_id from v151);

select * from T_score;

16、向成绩表中插入一些记录,这些记录要求符合以下条件:没有上过编号“103”课程的同学学号、2号课的平均成绩

create or replace view v161
as
select student_id, max(case when course_id = 103 then 1 else 0 end) aa
from T_score
group by student_id;

create or replace view v162
as
select b.student_id
from T_student b left join v161 a
                 on a.student_id = b.student_id 
where a.aa = 0 or a.aa is NULL;

create or replace view v163
as
select trunc(avg(score), 2) a
from T_score
where course_id = 102

insert into T_score  (select a.student_id, 103, b.a
                      from v162 a, v163 b)

17、按平均成绩从高到低显示所有学生的“数据库”、“Python”、两门的课程成绩,(数据库,Linux)按如下形式显示: 学生ID,数据库,Python,有效课程数,有效平均分

create or replace view v171
as   
select course_id
from t_course
where course_name = '数据库';

create or replace view v172
as
select course_id
from t_course
where course_name = 'linux';

select student_id 学号,
       sum(case when course_id = (select course_id from v171) 
                then score else NULL end) 数据库,
       sum(case when course_id = (select course_id from v172) 
                then score else NULL end) Linux,
       count(1) 有效课程数,
       avg(score) 有效平均分                                                                        
from T_score
where course_id in (select course_id
                    from t_Course
                    where course_name = '数据库' or course_name = 'linux')
group by student_id
order by 5 desc;--根据第五列排序

18、查询各科成绩最高和最低的分:以如下形式显示:课程ID,最高分,最低分

select course_id 课程ID, max(score) 最高分, min(score) 最低分
from T_score
group by course_id;

19、按各科平均成绩从低到高和及格率的百分数从高到低顺序

select course_id 课程ID, trunc(avg(score), 2) 平均成绩,
       trunc(sum(case when score >= 60 then 1 else 0 end) / count(1), 2) 及格百分比
from T_score
group by course_id
order by 2 ASC, 3 DESC;

20、查询如下课程平均成绩和及格率的百分数(用"1行"显示):(001),(002),(003),(004)

--方法一  
create or replace view v201 
as
select
round(100*sum(case when s.score>=60 and c.course_id=101 then 1 else 0 end)/
    sum(case when c.course_id=101 then 1 else 0 end),0)||'%' "101科目及格率",
round(100*sum(case when s.score>=60 and c.course_id=101 then 1 else 0 end)/
    sum(case when c.course_id=102 then 1 else 0 end),0)||'%' "102科目及格率",
round(100*sum(case when s.score>=60 and c.course_id=101 then 1 else 0 end)/
    sum(case when c.course_id=103 then 1 else 0 end),0)||'%' "103科目及格率",
round(100*sum(case when s.score>=60 and c.course_id=101 then 1 else 0 end)/
    sum(case when c.course_id=104 then 1 else 0 end),0)||'%' "104科目及格率",
round(100*sum(case when s.score>=60 and c.course_id=101 then 1 else 0 end)/
    sum(case when c.course_id=105 then 1 else 0 end),0)||'%' "105科目及格率"    
from t_score s, t_course c
where s.course_id=c.course_id;

select * from v201;
--方法二
create or replace view v202 
as
select course_id, count(1) aa
from T_score
group by course_id;

create or replace view v203
as
select course_Id, count(1) aa
from T_score
where score >= 60
group by course_id
order by aa;

select a.course_Id 学号, trunc(b.aa / a.aa * 100, 2) || '%' 及格率
from v202 a, v203 b
where a.course_id = b.course_id
order by b.aa/a.aa DESC

21、查询不同老师所教不同课程平均分从高到低显示

create or replace view v211
as
select course_id, trunc(avg(score) ,2) aa
from T_score   
group by course_id;

select c.t_name 教师姓名, a.aa 平均分
from v211 a, t_course b, t_teacher c
where a.course_Id = b.course_id and b.t_id = c.t_id
order by a.aa DESC;

22.查询如下课程成绩第 3 名到第 6 名的学生成绩单:1号课程,2号课程,3号课程,4号课程 [学生ID],[学生姓名],1号课程,2号课程,3号课程,4号课程,平均成绩

create or replace view v221
as
select student_id,
       sum(case when course_id = 101 then score else 0 end) aa,
       sum(case when course_id = 102 then score else 0 end) bb,
       sum(case when course_id = 103 then score else 0 end) cc,
       sum(case when course_id = 104 then score else 0 end) dd,
       avg(score) ee
from T_score
group by student_id
order by ee DESC;

select student_id, aa,  bb, cc, dd, rownum ff
from v221

select a.student_id, a.student_name, b.bb, b.cc, b.dd, b.ff
from T_student a, (select student_id, aa,  bb, cc, dd, rownum ff
                   from v221) b
where a.student_id = b.student_id and b.ff between 3 and 6;

23、统计各分数段人数显示结果如下:课程ID,课程名,<60人数,60<=x<80,>=80

create or replace view v231
as
select course_id,
       sum(case when score < 60 then 1 else 0 end) aa,
       sum(case when score between 60 and 79  then 1 else 0 end) bb,
       sum(case when score > 80 then 1 else 0 end) cc     
from T_score
group by course_id

select a.course_id 课程ID, course_name 课程名, a.aa "<60", a.bb "60~80", a.cc ">=80"
from v231 a, T_course b
where a.course_id = b.course_id;

24、查询学生平均成绩及其名次

create or replace view v241
as 
select student_id,
       trunc(avg(score), 2) aa
from T_score
group by student_id
order by aa DESC;

select a.student_id 学号, a.student_name 姓名, b.aa 平均成绩, b.bb 名次
from T_student a left join (select student_id, aa, rownum bb
                   from v241) b
on a.student_id = b.student_id   

25、查询各科成绩前三名的记录:(不考虑成绩并列情况)

create or replace view v251
as  
select max(score) aa
from T_score
group by course_id;

26、查询每门课程被选修的学生数

--方法一
select course_id 课程号, count(1) 人数
from T_score
group by course_id;  
--方法二
select sum(case when course_id = 101 then 1 else 0 end) "101",
       sum(case when course_id = 102 then 1 else 0 end) "102",
       sum(case when course_id = 103 then 1 else 0 end) "103",
       sum(case when course_id = 104 then 1 else 0 end) "104",
       sum(case when course_id = 105 then 1 else 0 end) "105"
from T_score

27、查询出只选修了一门课程的全部学生的学号和姓名

create or replace view v271
as
select student_id, count(1) aa
from T_score
group by student_id

select a.student_id, a.student_name
from T_student a, (select * from v271) b
where a.student_id = b.student_id  and b.aa = 1; 

28、查询男生、女生人数

--解法一 case when 可与decode互换
select sum(case when student_sex = 'M' then 1 else 0 end) 男生人数,
       sum(case when student_sex = 'F' then 1 else 0 end) 女生人数
from T_student
--解法二
select sum(decode(student_sex,'M', 1, 0)) 男生人数,
       sum(decode(student_sex,'F', 1, 0)) 女生人数
from T_student

29、查询姓“张”的学生名单

select *
from T_student
where student_name like '张%';

30、查询同名同姓学生名单,并统计同名人数

--方法一
select a.student_name 姓名, count(1) 人数
from  T_student a, T_student b
where a.student_name = b.student_name and a.student_id != b.student_id
group by a.student_name;
--方法二
select student_name 姓名, count(1) 人数
from T_student a
where student_name  in (select student_name 
                        from T_student where a.student_id != student_id)
group by student_name;  

30、1995年出生的学生名单(注:Student表中Sage列的类型是datetime)

--方法一
select To_Char (SYSDATE,'YYYY') "year" from dual;  
--方法二
select *
from T_student
where (to_char(SYSDATE,'YYYY') - 1995) = student_age;

32、查询每门课程的平均成绩,结果按平均成绩升序排列,平均成绩相同时,按课程号降序排列

select course_id 学号, trunc(avg(score), 2) 平均成绩
from T_score
group by course_id
order by 2 asc, course_id DESC

33、查询平均成绩大于85的所有学生的学号、姓名和平均成绩

create or replace view v331
as
select student_id, trunc(avg(score), 2) aa
from T_score
group by student_id

select a.student_id,b.student_name, a.aa
from v331 a, T_student b
where a.student_id = b.student_id and aa > 85

34、查询课程名称为“数据库”,且分数低于60的学生姓名和分数

--方法一
create or replace view v341
as
select student_id, score
from T_score
where course_id = (select course_id
                   from T_course 
                   where course_name = '数据库') and score < 80;

select b.student_name 姓名, a.score 成绩      
from v341 a, T_student b
where a.student_id = b.student_id;
--方法二
select c.student_name 姓名, b.score 成绩
from T_course a, T_score b, T_student c
where a.course_id = b.course_id and b.student_id = c.student_id 
      and a.course_name = '数据库' and b.score < 80

35、查询所有学生的选课情况(学生姓名、课程名称)

create or replace view v351
as
select a.student_id,a.student_name,b.course_id
from T_student a left join T_score b
on a.student_id = b.student_id

select student_id,
       max(case when b.course_name = '数据库' then '√' else NULL end) 数据库,
       max(case when b.course_name = 'QT' then '√' else NULL end) QT,
       max(case when b.course_name = 'C++' then '√' else NULL end) "C++",
       max(case when b.course_name = 'C语言' then '√' else NULL end) "C语言",
       max(case when b.course_name = 'linux' then '√' else NULL end) linix
from v351 a left join T_course b
on a.course_id = b.course_id
group by student_id
order by student_id;

36、查询任何一门课程成绩全部都在70分以上的姓名、课程名称和分数

create or replace view v361
as 
select a.student_id
from (select student_id,
             sum(case when score > 70 then 1 else 0 end) aa ,
             count(1) bb
      from T_score
      group by student_id) a, T_student b
where a.student_id = b.student_id and a.aa = a.bb;

select d.student_name, c.course_name,b.score
from v361 a, T_score b, T_course c, T_student d
where a.student_id = b.student_id and b.course_id  = c.course_id 
      and a.student_id = d.student_id

37、查询平均成绩不及格的课程,并按课程号从大到小排列

select course_Id 课程ID,trunc(avg(score), 2) 平均成绩
from T_score
group by course_id
having avg(score) < 80
order by course_id DESC

38、查询课程编号为003且课程成绩在80分以上的学生的学号和姓名

select a.student_id 学号, b.student_name 姓名
from T_score a, T_student b
where a.student_id = b.student_id and course_id = 103 and score > 80 

39、求选了课程的学生人数

select  count(distinct student_id) 学生人数 from T_score

40、查询选修“五木”老师所授课程中,每门成绩最高的学生姓名及其成绩。按如下个格式输出 课程名称 学生姓名 成绩(假设每门课最高分只有一个人)

create or replace view v401
as 
select b.course_id
from T_teacher a, T_course b
where a.t_id = b.t_id and a.t_name = '五木老师';

create or replace view v402
as 
select max(score) aa
from T_score a
where a.course_id in (select * from v401)
group by course_id;

select c.course_name 课程名称, b.student_name 姓名, a.score 成绩
from T_score a, T_student b, T_course c
where a.student_id = b.student_id and c.course_id = a.course_id 
      and a.score in (select * from v402)

41、查询各个课程及相应的选修人数

create or replace view v411
as 
select course_id, count(1) aa
from T_score  
group by course_id

select a.course_name 课程名, b.aa 人数
from t_Course a, v411 b
where b.course_Id = a.course_id;

42、查询不同课程成绩相同的学生的学号、课程号、学生成绩

select a.student_id 学号, a.course_Id 课程号, a.score 成绩
from T_score a, T_score b
where a.student_id = b.student_id and a.course_id != b.course_id and a.score = b.score;

43、查询每门功成绩最好的前两名

select * from t_score t
where (select count(1) 
       from t_score 
       where course_id=t.course_id and score > t.score) <= 1
order by course_id,score desc;

44、统计每门课程的学生选修人数(超过10人的课程才统计)。要求输出课程号和选修人数,查询结果按人数降序排列,查询结果按人数降序排列,若人数相同,按课程号升序排列

select course_id 课程号, count(1) 人数
from T_score
group by course_id
having count(1) >= 10
order by 2 DESC, course_id ASC

45、检索至少选修两门课程的学生学号

select student_id 学号
from T_score
group by student_id
having count(1) >= 2
order by student_id

46、查询全部学生都选修的课程的课程号和课程名

select b.course_id 课程ID, b.course_name 课程名
from T_score a, T_course b
where a.course_id = b.course_id
having count(1) = (select count(1) from T_student)
group by b.course_id, b.course_name

47、查询没学过“五木”老师讲授的任一门课程的学生姓名

--解法一
create or replace view v472
as
select a.student_name,
       sum(case when course_id in (select * from v471) then 1 else 0 end) aa
from T_student a left join T_score b
                 on a.student_id = b.student_id
group by a.student_id, a.student_name

select student_name 学生姓名
from   v472
where aa = 0 or aa is NULL;
--解法二
create or replace view v473
as
select distinct student_id
from T_score b
where course_id in (select course_id from v471)

select student_name
from T_student
where student_id not in(select * from v473)

48、查询两门以上不及格课程的同学的学号及其平均成绩 (小于70)

---解法一
create or replace view v481
as
select student_id, 
          sum(case when score < 70 then 1 else 0 end) aa,
          trunc(avg(score), 2) bb
from T_score
group by student_id;

select student_id 学号, bb 平均成绩
from v481
where aa >= 2;
--解法二
create or replace view v482
as
select student_id
from T_score
where score < 70
group by student_id
having count(1) >= 2;

select a.student_id 学号, trunc(avg(score), 2) 平均分
from T_score a, v482 b
where a.student_id = b.student_id
group by a.student_id;
--解法三
select a.student_id 学号, trunc(avg(score), 2) 平均分
from T_score a
where (select count(1)
       from T_score
       where a.student_id = student_id and score < 70) >= 2
group by a.student_id;
--解法四
create or replace view v483
as
select  a.student_id 
from T_score a, T_score b
where a.course_id = b.course_id and a.score < 70 and b.score < 70 and a.score != b.score
group by a.student_id
having count(1) >= 2 * 2;

select b.student_id 学号, trunc(avg(b.score), 2) 平均分 
from v483 a, T_score b
where a.student_id = b.student_id
group by b.student_id;

49、检索“004”课程分数小于60,按分数降序排列的同学学号

select student_id 学号, score 分数
from T_score
where course_Id = 104 and score < 70
order by score

50、删除“004”同学的“001”课程的成绩

delete from T_score where student_id = 4 and course_id = 101;  

把这些题多练习练习,大厂的sql题都难不倒你。加油!

  • 9
    点赞
  • 60
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 4
    评论
SQL是高级的非过程化编程语言,是沟通数据库服务器和客户端的重要工具,允许用户在高层数据结构上工作。它不要求用户指定对数据的存放方法,也不需要用户了解具体的数据存放方式,所以,具有完全不同底层结构的不同数据库系统,可以使用相同的SQL语言作为数据输入与管理的SQL接口。 它以记录集合作为操作对象,所有SQL语句接受集合作为输入,返回集合作为输出,这种集合特性允许一条SQL语句的输出作为另一条SQL语句的输入,所以SQL语句可以嵌套,这使它具有极大的灵活性和强大的功能,在多数情况下,在其他语言中需要一大段程序实现的功能只需要一个SQL语句就可以达到目的,这也意味着用SQL语言可以写出非常复杂的语句。    结构化查询语言(Structured Query Language)最早是IBM的圣约瑟研究实验室为其关系数据库管理系统SYSTEM R开发的一种查询语言,它的前身是SQUARE语言。SQL语言结构简洁,功能强大,简单易学,所以自从IBM公司1981年推出以来,SQL语言得到了广泛的应用。如今无论是像Oracle、Sybase、DB2、Informix、SQL Server这些大型的数据库管理系统,还是像Visual Foxpro、PowerBuilder这些PC上常用的数据库开发系统,都支持SQL语言作为查询语言。    美国国家标准局(ANSI)与国际标准化组织(ISO)已经制定了SQL标准。ANSI是一个美国工业和商业集团组织,负责开发美国的商务和通讯标准。ANSI同时也是ISO和International Electrotechnical Commission(IEC)的成员之一。ANSI 发布与国际标准组织相应的美国标准。1992年,ISO和IEC发布了SQL国际标准,称为SQL-92。ANSI随之发布的相应标准是ANSI SQL-92。ANSI SQL-92有时被称为ANSI SQL。尽管不同的关系数据库使用的SQL版本有一些差异,但大多数都遵循 ANSI SQL 标准。SQL Server使用ANSI SQL-92的扩展集,称为T-SQL,其遵循ANSI制定的 SQL-92标准。    SQL语言包含4个部分:    数据定义语言(DDL),例如:CREATE、DROP、ALTER等语句。    数据操作语言(DML),例如:INSERT(插入)、UPDATE(修改)、DELETE(删除)语句。    数据查询语言(DQL),例如:SELECT语句。    数据控制语言(DCL),例如:GRANT、REVOKE、COMMIT、ROLLBACK等语句。    SQL语言包括三种主要程序设计语言类别的语句:数据定义语言(DDL),数据操作语言(DML)及数据控制语言(DCL)。
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

林夕07

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值