oracle考试实训题代码.docx

上传人:大张伟 文档编号:11696175 上传时间:2021-08-31 格式:DOCX 页数:13 大小:16.46KB
返回 下载 相关 举报
oracle考试实训题代码.docx_第1页
第1页 / 共13页
oracle考试实训题代码.docx_第2页
第2页 / 共13页
oracle考试实训题代码.docx_第3页
第3页 / 共13页
oracle考试实训题代码.docx_第4页
第4页 / 共13页
oracle考试实训题代码.docx_第5页
第5页 / 共13页
点击查看更多>>
资源描述

《oracle考试实训题代码.docx》由会员分享,可在线阅读,更多相关《oracle考试实训题代码.docx(13页珍藏版)》请在三一文库上搜索。

1、P110 实训题1:请创建一个表空间 books_pub ,其中包含一个数据文件,数据文件初始化大小为500MB,不允许自动扩展。 87create tablespace books_pubdatafile C:oracleproduct10.2.0oradataorclbooks_pub_01.dbfsize 500M reuse;之后修改表空间, 为其添加一个数据文件, 该文件初始化大小为200MB, 并且允许自动扩展。alter tablespace books_pubadd datafile C:oracleproduct10.2.0oradataorclbooks_pub_02.db

2、fsize 200M reuseautoextend on next 5M maxsize unlimited; P882、请创建一个16K 的非标准块表空间。 P90先设置初始化参数:alter system set db_16k_cache_size = 40M;才能创建表空间:create tablespace demoedatafile d:oracleoradataorcldemoE01,dbf size 20M blocksize 16K;4、在数据库内创建一个临时表空间,把它设置为scott 用户的默认临时表空间。scott 用户解锁: P118alter user scott

3、account unlock;没有密码alter user scott identified by tiger account unlock;有密码 tiger创建临时表空间: P96create temporary tablespace temp1tempfile d:oracleoradataorclusrtemp01,dbf size 100M reuseextent management local uniform size 4M;设置为 scott 用户的默认临时表空间: P97alter user scott temporary tablespace temp1;P140 实训题1

4、:请创建一个用户books_pub ,要求他第一次登录时必须修改口令,将其默认表空间和默认临时表空间分别设置为books_pub和temp,并在表空间 users、demots、和books_pub上分别为他分配 10MB 10MB和50MB的存储空间。见 P110 实训题 1demots 表空间:P87create tablespace demotsdatafile C:oracleproduct1020oradataorcldemots.dbfsize 100M reuse;用户:口令为 bookspub , 口令自己设create user books_pubidentified by

5、bookspubpassword expiredefault tablespace books_pubtemporary tablespace tempquota 50M on books_pubquota 10M on usersquota 10M on demots;2:把创建会话的系统权限,以及 scott用户dept表和emp表上的所有对象授予用户 books_pub。scott用户解锁:P118alter user scott account unlock;没有密码alter user scott identified by tiger account unlock;有密码 tige

6、r授权:P130grant create session to books_pub;grant insert,delete,update,select on scott.dept to books_pub;grant insert,delete,update,select on scott.emp to books_pub;3:创建一个角色,把创建常用数据库对象(如表、索引、视图、同义词、序列)的权限授予角色,之后,把用户 books_pub加入到该角色,并设置为其默认角色。创建角色:P132create role role_04;角色为 role_04 ,没有密码create role ro

7、le_04 identified by orcl;有密码,密码为 orcl把创建表、索引、视图、同义词、序列的权限授予角色:P133grant create session to role_04;必须有的Grant connect to role_04;grant create table to role_04;表grant create index to role_04;索弓 Igrant create view to role_04;视图grant create synonym to role_04;同义词grant create sequence to role_04;序歹!J把用户bo

8、oks_pub加入到该角色:P133grant role_04 to books_pub;设置为其默认角色:P135前提是该角色不采用数据库验证方式,即不设口令alter user books_pub default role role_04;4:创建一个概要文件,使用它对用户做出以下限制:用户账户并发会话数量最多为5;用户会话空闲15min后断开;用户登录连续失败 3次后锁定其账户。把概要文件指派给用户books_pub,并使用该账户链接测试以上限制。创建概要文件:P120create profile pro_04 limitsessions_per_user 5idle_time 15fa

9、iled_login_attempts 3;启用资源限制:P121alter system set resource_limit=TRUE;指派:P121alter user books_pub profile pro_04;测试:P122 set time on conn books_pub/orcl orcl select * from dept;P179实训题1:创建 type、 books、 publishers 和 orders4 个表。创建表type : P151 create table type( typeid number(6) primary key, typename v

10、archar2(20) not null);alter table type modify typename unique;创建表books :create table books(bookid number(6) primary key,booknum varchar2(6),bookname varchar2(60) not null, pubid number(6), bookprice number(8,2), typeid number(6) references type (typeid), booktime date, salescount integer);创建表 publis

11、hers :create table publishers(pubid number(6) primary key, pubname varchar2(40) not null, city varchar2(20),state varchar2(10),country varchar2(30) );创建表 orders :create table orders(orderid number(6) primary key,ordernum varchar2(20) not null,orddate date,qty integer,payterms varchar2(12),bookid num

12、ber(6);2:为表books 添加两列 content 和 img 。 P155alter table books add (content long,img varchar2(50);3、为表books的booknum列添加唯一性约束和非空约束。163alter table books modify booknum unique; 唯一性约束alter table books modify booknum not null;非空约束为列 pubid 添加可延迟的外键约束,该列参照表publishers 的 pubid 列。 P166alter table books add foreig

13、n key (pubid) references publishers (pubid) on delete cascade deferrable initially deferred;4、修改表orders ,为列 oradate 设置默认值,其取值来自 SYSDATE.alter table orders modify oradate date default sysdate;为列 bookid 添加外键约束,它参照 books 表中的 bookid 列。alter table orders add foreign key (bookid) references books (bookid)

14、on delete cascade;SQL create tablespace books_pub2 datafile D:OracleOracleoradataorclbooks_pub_01.dbfsize500m3 autoextend off;表空间已创建。SQL alter tablespace books_pub2 add datafileD:OracleOracleoradataorclbooks_pub_02.dbfsize200m3 autoextend on;表空间已更改。SQL create user books_pub4 identified by zhw205 def

15、ault tablespace books_pub6 quota 50m on books_pub;用户已创建。SQL create role sr_zhw7 identified by zhw;角色已创建。SQL grant create table to sr_zhw;授权成功。SQL grant create view to sr_zhw;授权成功。SQL grant create sequence to sr_zhw;授权成功。SQL grant create synonym to sr_zhw;授权成功。SQL grant connect to sr_zhw;授权成功。SQL gra

16、nt sr_zhw to books_pub;授权成功。SQL alter user books_pub2 default role sr_zhw;用户已更改。SQL create sequence books_seq3 start with 14 maxvalue 1000005 cache 106 ;序列已创建。SQL create sequence type_seq7 start with 18 maxvalue 1000009 cache 10;序列已创建。SQL create table type(2 typeid number(6) primary key,3 typename v

17、archar2(20)4 )5 tablespace books_pub;表已创建。SQL alter table type6 add constraint t_un unique;add constraint t_un unique*第 2 行出现错误:ORA-00906: 缺失左括号SQL alter table type7 modify typename constraint t_un unique;表已更改。SQL alter table type8 modify typename constraint t_nk not null;表已更改。SQL create table books

18、9 (bookid number(6) primary key,10 booknum varchar2(6),11 bookname varchar2(60) not null,12 pubid number(6),13 bookprice number(8,2),14 typeid number(6) constraint b_fk references type(typeid),15 booktime date,16 salecount integer17 )18 tablespace books_pub;表已创建。SQL alter table books2 drop constrain

19、t b_fk;表已更改。SQL alter table books2 add constraint b_fk foreign key (typeid) references type (typeid) deferrable initially deferred;表已更改。SQL drop sequence books_seq;序列已删除。SQL drop sequence type_seq;序列已删除。SQL CREATE SEQUENCE books_seq2 START WITH 1003 INCREMENT BY 14 MAXVALUE 1000005 CACHE 206 NOCYCLE

20、;序列已创建。SQL select books_seq.nextval from dual;NEXTVAL100SQL select books_seq.currval from dual;CURRVAL100SQL insert into books2 values(books_seq.currval,DB1001, 数据库原理, , 40.8, ,10-1 月 -09, 1100);已创建 1 行。SQL insert into books2 values(books_seq.nextval,DB1002, Oracle 10g入门与提高, ,35.9, , 7-7 月 -08, 200)

21、;已创建 1 行。SQL insert into books2 values(books_seq.nextval,DB1003, 数据库原理基础教程, ,37.8, 1-7 月 -08, 1000);已创建 1 行。SQL insert into books2 values(books_seq.nextval,DB1004, Oracle 10g PL/SQL开发人员指南, , 47.9, , 10-3月-06, 130);已创建 1 行。SQL insert into books2SQL insert into books2 values(books_seq.nextval,DB1005,

22、数据库原理基础教程, ,32.8, 10-3 月 -07, 250);已创建 1 行。大型数据库技术, , 30.5,SQL insert into books2 values(books_seq.nextval,DB1006, 1-11 月 -08, 1560);1 行。SQL insert into books2 values(books_seq.nextval,SX2001, 月 -07, 0);已创建 1 行。SQL insert into books2 values(books_seq.nextval,DS3001, , 15-3 月 -07, 2300);已创建 1 行。SQL i

23、nsert into books2 values(books_seq.nextval,PL4001, 1-5 月 -07, 800);, ,48.2, , 1-11数据结构(C语言版),”,37.8,C+语言程序设计,37.9, ”1 行。SQL CREATE SEQUENCE type_seq2 START WITH 103 INCREMENT BY 14 MAXVALUE 1000005 NOCYCLE;序列已创建。SQL select type_seq.nextval from dual;NEXTVAL10SQL select type_seq.currval from dual;CUR

24、RVAL10SQL insert into type2 values(type_seq.currval,XX_DB);已创建 1 行。SQL insert into type2 values(type_seq.nextval,ZR_MATH);已创建 1 行。SQL insert into type2 values(type_seq.nextval,XX_DS);已创建 1 行。SQL insert into type2 values(type_seq.nextval,XX_PL);已创建 1 行。SQL insert into type2 values(type_seq.nextval,WX

25、_ZJ);1 行。SQL alter table books2 add(stars varchar2(100)3 ;表已更改。SQL select * from books;BOOKID BOOKNU BOOKNAMEPUBID BOOKPRICE TYPEID BOOKTIME SALECOUNTSTARS105 DB1006 大型数据库技术30.501-11月-081560106 SX2001 高等数学48.201-11月-070BOOKID BOOKNU BOOKNAMEPUBID BOOKPRICE TYPEID BOOKTIME SALECOUNTSTARS107 DS3001数据结

26、构(C语言版)37.815-3月 -072300108 PL4001 C+ 语言程序设计37.901-5月 -07800BOOKID BOOKNU BOOKNAMEPUBID BOOKPRICE TYPEID BOOKTIME SALECOUNTSTARS100 DB1001 数据库原理40.810-1月 -091100101 DB1002 Oracle 10g 入门与提高BOOKID BOOKNU BOOKNAMEPUBID BOOKPRICE TYPEID BOOKTIME SALECOUNTSTARS35.907-7月 -08200102 DB1003 数据库原理基础教程37.801-7月 -081000BOOKID BOOKNU BOOKNAMEPUBID BOOKPRICE TYPEID BOOKTIME SALECOUNTSTARS103 DB1004 Oracle 10g PL/SQL 开发人员指南47.910-3月 -06130104 DB100532.8数据库原理基础教程10-3月 -07250BOOKID BOOKNU BOOKNAMEPUBID BOOKPRICE TYPEID BOOKTIME SALECOUNTSTARS已选择 9 行。SQL spo off;实验考试

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 科普知识


经营许可证编号:宁ICP备18001539号-1