亚洲免费在线-亚洲免费在线播放-亚洲免费在线观看-亚洲免费在线观看视频-亚洲免费在线看-亚洲免费在线视频

oracle_面試題01

系統 1757 0

完成下列操作,寫出相應的SQL語句

創建表空間neuspace,數據文件命名為neudata.dbf,存放在d:\data目錄下,文件大小為200MB,設為自動增長,增量5MB,文件最大為500MB。(8分)
答:create tablespace neuspace datafile ‘d:\data\neudata.dbf’ size 200m auto extend on next 5m maxsize 500m;
2. 假設表空間neuspace已用盡500MB空間,現要求增加一個數據文件,存放在e:\appdata目錄下,文件名為appneudata,大小為500MB,不自動增長。(5分)
答:alter tablespace neuspace add datafile ‘e:\appdata\appneudata.dbf’ size 500m;
3. 以系統管理員身份登錄,創建賬號tom,設置tom的默認表空間為neuspace。為tom分配connect和resource系統角色,獲取基本的系統權限。然后為tom分配對用戶scott的表emp的select權限和對SALARY, MGR屬性的update權限。(8分)
答:create user tom identified by jack default tablespace neuspace;
Grant connect, resource to tom;
Grant select, update(salary, mgr) on scott.emp to tom;
4. 按如下要求創建表class和student。(15分)
屬性
類型(長度)
默認值
約束
含義

CLASSNO 數值 (2) 無 主鍵 班級編號
CNAME 變長字符 (10) 無 非空 班級名稱
屬性
類型(長度)
默認值
約束
含義

STUNO 數值 (8) 無 主鍵 學號
SNAME 變長字符 (12) 無 非空 姓名
SEX 字符 (2) 男 無 性別
BIRTHDAY 日期 無 無 生日
EMAIL 變長字符 (20) 無 唯一 電子郵件
SCORE 數值 (5, 2) 無 檢查 成績
CLASSNO 數值 (2) 無 外鍵,關聯到表CLASS的CLASSNO主鍵 班級編號
答:create table class
(classno number(2) constraint class_classno_pk primary key,
cname varchar2(10) not null);
create table student
(stuno number(8) constraint student_stuno_pk primary key,
sname varchar2(12) not null,
sex char(2) default ‘男’,
birthday date,
email varchar2(20) constraint student_email_uk unique,
score number(5,2) constraint student_score_ck check(score>=0 and score<=100),
classno number(2) constraint student_classno_fk references class(classno)
);
5. 在表student的SNAME屬性上創建索引student_sname_idx(5分)
答:create index student_sname_idx on student(sname);
6. 創建序列stuseq,要求初值為20050001,增量為1,最大值為20059999。(6分)
答:create sequence stuseq increment by 1 start with 20050001 maxvalue 20059999 nocache nocycle;
7. 向表student中插入如下2行。(5分)
STUNO SNAME SEX BIRTHDAY EMAIL SCORE CLASSNO
從stuseq取值 tom 男 1979-2-3 14:30:25 tom@163.net 89.50 1
從stuseq取值 jerry 默認值 空 空 空 2
答:insert into student values(stuseq.nextval, ’tom’, ’男’, to_date(‘1979-2-3
14:30:25’, ’yyyy-mm-dd fmhh24:mi:ss’), ’tom@163.net’, 89.50, 1);
insert into student (stuno, sname, classno) values(stuseq.nextval, ’jerry’, 2);
8. 修改表student的數據,將所有一班的學生成績加10分。(4分)
答:update student set score=score+10 where classno=1;
9. 刪除表student的數據,將所有3班出生日期小于1981年5月12日的記錄刪除。(4分)
答:delete from student where classno=3 and birthday > ’12-5月-81’;
10. 完成以下SQL語句。(40分)
(1) 按班級升序排序,成績降序排序,查詢student表的所有記錄。
答:select * from student order by classno, score desc;
(2) 查詢student表中所有二班的成績大于85.50分且出生日期大于1982-10-31日的男生的記錄。
答:select * from student where classno=2 and score>85.50 and birthday < ’31-10月-82’ and sex=’男’;
(3) 查詢student表中所有三班成績為空的學生記錄。
答:select * from student where classno=3 and score is null;
(4) 表student與class聯合查詢,要求查詢所有學生的學號,姓名,成績,班級名稱。(使用oracle與SQL 99兩種格式)
答:select s.stuno, s.sname, s.score, c.cname from student s, class c where s.classno=c.classno;
(5) 按班級編號分組統計每個班的人數,最高分,最低分,平均分,并按平均分降序排序。
答:select classno, count(*), max(score), min(score), avg(score) from student group by classno order by avg(score) desc;
(6) 查詢一班學生記錄中所有成績高于本班學生平均分的記錄。
答:select * from student where classno=1 and score > (select avg(score) from student where classno=1);
(7) 統計二班學生中所有成績大于所有班級平均分的人數。
答:select count(*) from student where classno=2 and score > all (select avg(socre) from student group by classno);
(8) 查詢平均分最高的班級編號與分數。
答:select classno, avg(score) from student group by classno having avg(score) = (select max(avg(score)) from student group by classno);
(9) 查詢所有學生記錄中成績前十名的學生的學號、姓名、成績、班級編號。
答:select stuno, sname, score, classno from (select * from student order by score desc) where rownum<=10;
(10) 創建視圖stuvu,要求視圖中包含student表中所有一班學生的stuno, sname, score, classno四個屬性,并具有with check option限制。
答:create view stuvu
as
select stuno, sname,score,classno from student where classno=1 with check option;

oracle_面試題01


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 日韩中文字幕一在线 | 中国妞xxx的视频 | 色综合色狠狠天天综合色hd | 视频一区在线播放 | 精品欧美一区二区在线观看 | 四虎影视国产永久免费 | 日日操夜夜操天天操 | 久久久久久99精品 | 国产一级视频在线观看 | 美女视频黄的免费视频网页 | 欧美一级视频免费看 | 乱码一区二区三区完整视频 | 伊人伦理| 狠狠涩| 日本一级毛片不卡免费 | a拍拍男女免费看全片 | www.男人的天堂.com | 男人天堂网在线观看 | 人人爽天天爽夜夜爽qc | 日日操日日摸 | 老子影院午夜伦不卡不四虎卡 | 亚洲图片国产日韩欧美 | 久久亚洲精品玖玖玖玖 | 日本三级日本三级人妇三级四 | 久久久婷婷亚洲5月97色 | 2021国产精品系列一区二区 | 影音先锋在线亚洲精品推荐 | 视频福利网 | 手机看片国产永久1204 | 色综合久久天天综线观看 | 亚洲美女激情 | 豆国产97在线 | 亚洲 | 日本一级爽爽爽爽 | 国产成人综合亚洲欧美在 | a v在线男人的天堂观看免费 | 天天色综合色 | 亚洲无限看 | 国产成人三级 | 天天看片夜夜爽 | www.xxx欧美 | 国产丶欧美丶日韩丶不卡影视 |