SQL第三题

君,已阅读到文档的结尾了呢~~
广告剩余8秒
文档加载中
《SQLServer实用教程》(..
扫扫二维码,随身浏览文档
手机或平板扫扫即可继续访问
《SQLServer实用教程》(第三版)试题及答案
举报该文档为侵权文档。
举报该文档含有违规或不良信息。
反馈该文档无法正常浏览。
举报该文档为重复文档。
推荐理由:
将文档分享至:
分享完整地址
文档地址:
粘贴到BBS或博客
flash地址:
支持嵌入FLASH地址的网站使用
html代码:
&embed src='/DocinViewer-4.swf' width='100%' height='600' type=application/x-shockwave-flash ALLOWFULLSCREEN='true' ALLOWSCRIPTACCESS='always'&&/embed&
450px*300px480px*400px650px*490px
支持嵌入HTML代码的网站使用
您的内容已经提交成功
您所提交的内容需要审核后才能发布,请您等待!
3秒自动关闭窗口数据库原理及应用(SQL Server 2008)第三章习题及实验答案_图文_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
您可以上传图片描述问题
联系电话:
请填写真实有效的信息,以便工作人员联系您,我们为您严格保密。
数据库原理及应用(SQL Server 2008)第三章习题及实验答案
||暂无简介
助理工程师|
总评分4.3|
浏览量1421341
试读已结束,如果需要继续阅读或下载,敬请购买
你可能喜欢君,已阅读到文档的结尾了呢~~
广告剩余8秒
文档加载中
扫扫二维码,随身浏览文档
手机或平板扫扫即可继续访问
SQL+server+实用教程第三版试题有及答案
举报该文档为侵权文档。
举报该文档含有违规或不良信息。
反馈该文档无法正常浏览。
举报该文档为重复文档。
推荐理由:
将文档分享至:
分享完整地址
文档地址:
粘贴到BBS或博客
flash地址:
支持嵌入FLASH地址的网站使用
html代码:
&embed src='/DocinViewer-4.swf' width='100%' height='600' type=application/x-shockwave-flash ALLOWFULLSCREEN='true' ALLOWSCRIPTACCESS='always'&&/embed&
450px*300px480px*400px650px*490px
支持嵌入HTML代码的网站使用
您的内容已经提交成功
您所提交的内容需要审核后才能发布,请您等待!
3秒自动关闭窗口3605人阅读
Oracle(17)
考试总分为100分,共8题,时间为1小时。
表结构说明:
create table employee(
id number(10) not null, -- 员工工号
salary number(10,2) default 0 not null, -- 薪水
name varchar2(24) not null -- 姓名
1.创建序列seq_employee,该序列每次取的时候它会自动增加,从1开始计数,不设最大值,并且一直累加,不循环。(10分)
2.写一个PL/SQL块,插入表user.employee中100条数据。插入该表中字段id用序列seq_employee实现,薪水和姓名字段可以任意填写。(15分)
3.写一个语句块,在语句块中定义一个显式游标,按id升序排列,打印表employee中前十条数据。(15分)
4.创建存储过程p_employee,输入员工薪水范围,返回员工工号、姓名、薪水结果集,结果集按员工薪水升序排列。(15分)
5.创建函数f_employee实现更新员工薪水的功能,将薪水低于2000且姓wang的员工薪水加5%,其他不变,更新成功则返回0,否则返回1。(15分)
6.写一个匿名语句块,用于执行函数f_employee,并打印执行该函数的结果。(8分)
7.创建存储过程p_create_emp,用于判断表employee是否存在,如果存在则删除该表。(15分)
8.写一个匿名语句块,用于执行存储过程p_create_emp。(7分)
答案如下:
1 ---参考答案
create sequence seq_employee
increment by 1
start with 1
nomaxvalue
2 -----参考答案
a number:=1;
insert into employee values(seq_employee.nextval,a,'tom');
a:=a+1;
exit when a&100;
3 ------答案
vname varchar2(30);
a number :=1;
cursor cur_employee is select id,salary,name from
fetch cur_employee into vid,vsalary,
dbms_output.put_line(vid||' '||vsalary||' '||vname);
a:=a+1;
exit when a&10;
end loop;
close cur_
下面的是同学写的:
cursor mycur is select * from employee where rownum&=10
record employee%
if mycur%isopen then
dbms_output.put_line(record.id);
exit when mycur%
4 ------参考答案
create or replace procedure p_employee(vsalary number,vsalary2 number)
v_name varchar2(30);
cursor cur_employee is select id,salary,name from employee
&&&&&&&&&&&&&&&&&&&&&& where salary between &vsalary and &vsalary2
fetch cur_employee into v_id,v_salary,v_
dbms_output.put_line(v_id||' '||v_salary||' '||v_name);
exit when cur_employee %
5 -----答案
create or replace function f_employee return number
&&& update employee set salary=salary+salary*0.05 where salary&2000 and name like 'wang%';
&&& if sql%rowcount=0 then
&&&&& return 1;
&&&&& return 0;
6 ---参考答案
a:=f_employee();
dbms_output.put_line(a);
7 ----参考答案
create or replace procedure p_create_emp
select count(*) into v_count from user_tables where table_name='EMPLOYEE';
if v_count=0 then
execute immediate 'drop table employee';
下面的是网上别人编写的参考答案
答案如下:
SQL& create table employee(
2 id number(10) not null, -- 员工工号
3 salary number(10,2) default 0 not null, -- 薪水
4 name varchar2(24) not null -- 姓名
表已创建。
---第一题答案:
SQL& Create sequence seq_employee increment by 1 start with 1
序列已创建。
---第二题答案:
3 for i in 1 .. 100
5 insert into employee
6 values(seq_employee.nextval,1950+i,'王明'||to_char(i));
PL/SQL 过程已成功完成。
SQL& select * from employee where rownum&11;
ID SALARY NAME
---------- ---------- ------------------------
1 1951 王明1
2 1952 王明2
3 1953 王明3
4 1954 王明4
5 1955 王明5
6 1956 王明6
7 1957 王明7
8 1958 王明8
9 1959 王明9
10 1960 王明10
已选择10行。
-------第三题答案:
SQL& declare
2 cursor c is select id,salary,name from(select * from employee order by id) where rownum&11;
3 v_record c%
7 fetch c into v_
8 exit when c%
9 dbms_output.put_line(to_char(v_record.id)||','||to_char(v_record.salary)||','||v_record.name);
1,1951,王明1
2,1952,王明2
3,1953,王明3
4,1954,王明4
5,1955,王明5
6,1956,王明6
7,1957,王明7
8,1958,王明8
9,1959,王明9
10,1960,王明10
PL/SQL 过程已成功完成。
-------第四题答案
SQL& create or replace procedure p_employee
2 (iminsalary in number,
3 imaxsalary in number)
6 for x in(select id,salary,name from(select * from employee where salary between iminsalary and imaxsalary) order by salary)
8 dbms_output.put_line(to_char(x.id)||to_char(x.salary)||x.name);
过程已创建。
SQL& exec p_employee();
502000王明50
512001王明51
522002王明52
532003王明53
542004王明54
552005王明55
562006王明56
572007王明57
PL/SQL 过程已成功完成。
---------第五题答案
SQL& create or replace function f_employee return number
update employee set salary=salary+salary*0.05 where salary&2000 and name like '王%';
if sql%rowcount=0 then
函数已创建。
-----第六题答案
3 a:=f_employee();
4 dbms_output.put_line(to_char(a));
PL/SQL 过程已成功完成。
SQL& select * from employee where salary&2000 and name like '王%';
SQL& select * from employee where rownum&50;
ID SALARY NAME
---------- ---------- ------------------------
1 2048.55 王明1
2 2049.6 王明2
3 2050.65 王明3
4 2051.7 王明4
5 2052.75 王明5
6 2053.8 王明6
7 2054.85 王明7
8 2055.9 王明8
9 2056.95 王明9
10 2058 王明10
11 2059.05 王明11
ID SALARY NAME
---------- ---------- ------------------------
12 2060.1 王明12
13 2061.15 王明13
14 2062.2 王明14
15 2063.25 王明15
16 2064.3 王明16
17 2065.35 王明17
18 2066.4 王明18
19 2067.45 王明19
20 2068.5 王明20
21 2069.55 王明21
22 2070.6 王明22
ID SALARY NAME
---------- ---------- ------------------------
23 2071.65 王明23
24 2072.7 王明24
25 2073.75 王明25
26 2074.8 王明26
27 2075.85 王明27
28 2076.9 王明28
29 2077.95 王明29
30 2079 王明30
31 2080.05 王明31
32 2081.1 王明32
33 2082.15 王明33
ID SALARY NAME
---------- ---------- ------------------------
34 2083.2 王明34
35 2084.25 王明35
36 2085.3 王明36
37 2086.35 王明37
38 2087.4 王明38
39 2088.45 王明39
40 2089.5 王明40
41 2090.55 王明41
42 2091.6 王明42
43 2092.65 王明43
44 2093.7 王明44
ID SALARY NAME
---------- ---------- ------------------------
45 2094.75 王明45
46 2095.8 王明46
47 2096.85 王明47
48 2097.9 王明48
49 2098.95 王明49
已选择49行。
-----第七题答案
SQL& create or replace procedure p_create_emp
5 select count(*) into v_count from user_tables where table_name='EMPLOYEE';
6 if v_count=0 then
9 execute immediate 'drop table employee';
过程已创建。
---------第八题答案
SQL& exec p_create_
PL/SQL 过程已成功完成。
SQL& select *
select * from employee
ERROR 位于第 1 行:
ORA-00942: 表或视图不存在
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:430994次
积分:5396
积分:5396
排名:第3020名
原创:129篇
转载:49篇
评论:63条
(1)(1)(2)(1)(3)(1)(4)(3)(5)(11)(1)(4)(10)(1)(2)(2)(5)(16)(13)(9)(4)(10)(4)(8)(10)(2)(4)(5)(15)(10)(3)(1)(6)(1)君,已阅读到文档的结尾了呢~~
精品:第三章公司法习题 第三章..
扫扫二维码,随身浏览文档
手机或平板扫扫即可继续访问
第三章SQL语言习题
举报该文档为侵权文档。
举报该文档含有违规或不良信息。
反馈该文档无法正常浏览。
举报该文档为重复文档。
推荐理由:
将文档分享至:
分享完整地址
文档地址:
粘贴到BBS或博客
flash地址:
支持嵌入FLASH地址的网站使用
html代码:
&embed src='/DocinViewer-4.swf' width='100%' height='600' type=application/x-shockwave-flash ALLOWFULLSCREEN='true' ALLOWSCRIPTACCESS='always'&&/embed&
450px*300px480px*400px650px*490px
支持嵌入HTML代码的网站使用
您的内容已经提交成功
您所提交的内容需要审核后才能发布,请您等待!
3秒自动关闭窗口

我要回帖

更多关于 sql笔试题 的文章

 

随机推荐