1、 (5) SYSMAN:该用户是企业管理的超级管理员账号,该账号能够创建和修改其他管理员账号,同时也能管理数据库实例。(6) DBSNMP:是Oracle数据库中用于智能代理(Intelligent Agent)的用户,用来监控和管理数据库相关性能。如果停止该用户,则无法提取相关的数据库信息。(7) 方法一:点击“开始”“程序” “Oracle - ”“Application Development”“SQL Plus” 进入Windows环境下的图形窗口(8) 方法二:“运行”输入“cmd命令”进入DOS环境下执行SQLPLUS命令也可以打开SQL*Plus工具。(9) 方式三:在IE浏览器
2、地址栏中输入2.6 习题一、 填空题1. 数据、日志、控制、初始化参数 数据 控制 初始化参数2. 表空间、段、盘区、数据块 盘区 数据块3. 数据 段 盘区4. 用户进程 服务进程 后台进程 用户进程 服务进程5. 数据 重做日志6. 修改过的数据 数据文件7. 重做日志缓冲区内的日志 重做日志8. 日志条目 归档日志设备 归档9. 共享服务器 专有服务器 共享服务器 共享服务器二、 简答题1. Oracle数据库的物理存储结构式从物理组成的角度分析一个数据库在存储介质上的实际构成,它是由操作系统组织和管理的,是Oracle数据库的外部存储结构。(1) 数据文件:数据文件时Oracle数据库
3、用来存储各种数据的地方,如表中的记录、索引数据、系统数据和临时数据等。(2) 日志文件:在Oracle中,日志文件记录了用户对数据的修改信息(如增加、删除、修改),名字通常为READ*.LOG格式。(3) 控制文件:控制文件时Oracle数据库的物理文件之一,它是一个很小的二进制文件,记录了数据库的名称、数据文件和连击日志文件的名称及位置、当前的日志序列号、表空间等信息。(4) 参数文件:参数文件中记录着数据库名称、控制文件的路径、SGA的内存结构、可选的Oracle特性和后台进程的配置参数等信息。(1) Oracle数据库逻辑存储结构是Oracle数据库创建后利用逻辑概念来描述数据库内部数据
4、的组织和管理形式。包括表空间、段、区和块四种。(2) 表空间和数据文件的关系:数据库中的一个表空间至少包含一个或多个数据文件,而一个数据文件只能属于一个表空间。这种关联实现了数据库的逻辑存储结构和物理存储结构的统一。(1) 数据库实例是用户访问数据库的中间层,是使用数据库的手段,它为用户访问数据库提供了必要的内存空间和多个Oracle进程,它是动态的、临时的。一个Oracle实例由内存空间和Oracle进程两部分组成。(2) 数据库和数据库实例是相辅相成、缺一不可的。如果只有数据库的物理文件,只能说明有数据被存储在数据库中,但是无法直接访问。如果只有数据库实例,说明为数据库的使用做好了准备、可
5、以访问数据库,但不知道要操作的数据在哪里。(1) 客户端配置a) sqlnet.ora文件用于指定数据库连接账号的验证方式以及连接字符串的解析方式,也就是说通过该文件决定怎样查找一个连接中出现的连接字符串的定义。b) tnsnames.ora文件时Oracle客户端的另一个重要文件,用来定义客户端连接远程服务器时的主机字符串。(2) 服务器端配置一、 listener.ora文件作用于Oracle数据库服务器端,是Oracle监听服务的配置文件。当客户端向服务器提交连接请求时,由监听服务接受并对连接账号进行有效验证,验证通过后将用户进程交给服务进程处理。若该文件被破坏,将影响监听服务的正常使用
6、。3.5 习题一、 选择题1. C 2. C 3. B1. 一个方案只能被一个数据库用户拥有,并且方案名称与这个用户的名称相同。创建新用户时系统自动创建该用户的方案。数据库的每一个用户都拥有一个唯一的方案。该用户创建的方案对象默认被保存在自己的方案中。2. CREATE USER创建新用户命令:(1) USER-NAME :新创建的用户名称。(2) PASSWORD:为新用户制定密码。(3) DEFAULT TABLESPACE: 为新用户指定默认表空间。用来储存该用户创建的方案对象 。(4) TEMPORARY TABLESPACE: 为用户指定临时表空间,存储操作过程中产生的临时数据。(5
7、) QUOAT: 为新用户指定磁盘配额,表示该用户在指定的空间中可以占用的最大磁盘空间。(6) UNLIMITED: 表示该用户可以使用无限大的空间。(7) PROFILE: 指定新用户使用的配置文件。(8) PASSWORD expire:表示新用户密码过期,登陆后需要给出新密码。(9) ACCOUNT lock/unlock : 表示用户加锁/解锁状态。其中,用户名和密码是必须有的。三、 操作题1. CREATE USER ORA_TEMP IDENTIFIED BY TEM;2. ALTER USER ORA_TEMP IDENTIFIED BY ORA;3. ALTER USER OR
8、A_TEMPACCOUNT LOCK;4.5 实验a) create table student(sno char(10) primary key,sname varchar2(8),sex char(2) default 男 check(sex=男 or sex=女),birthday date,sdept char(20);b) create table course(cno char(10) primary key,cname char(30) unique,ccredit number(3)c) create table score(sno char(10) references st
9、udent(sno),cno char(10) references course(cno), grade number(3) check(grade=0 and gradesal;(4) select * from scott.emp where commsal*0.2;(5) select * from scott.emp where (deptno=10 and job=MANAGER) or (deptno=20 and job=(6) select * from scott.emp where job not in() and sal=2000;(7) select * from s
10、cott.emp where comm is not null;(8) select count(empno),avg(sal) from scott.emp;(9) select * from scott.emp where comm is null or comm100(10) select * from scott.emp where (sysdate-hiredate)/365=10;(12) select initcap(lower(ename) from scott.emp;(13) select * from scott.emp where length(ename)=6;(14
11、) select * from scott.emp where ename not like %S%(15) select * from scott.emp where ename like _M%(16) select substr(ename,1,3) from scott.emp;(17) select replace(ename,sS) from scott.emp;(18) select ename,hiredate from scott.emp order by hiredate;(19) select ename,job,sal from scott.emp order by j
12、ob desc,sal asc;(20) select ename,extract(year from hiredate) as 年份,extract(month from hiredate) as 月份 from scott.emp order by 月份,年份;(21) select deptno,count(*),avg(sal),avg(sysdate-hiredate)/365) from scott.emp group by deptno;(22) select count(*),avg(sal) from scott.emp group by deptno;(23) select
13、 min(sal),job from scott.emp group by job having min(sal)3000;(24) select deptno,job,max(sal) from scott.emp group by deptno,job;(25) select count(*),avg(sal) from scott.emp group by job;5.6 习题1. C 2. A 3. A 4. A 5. C 6.A 7. B 8. C 9. A 10. B6.5 习题(1)select ename,dname from scott.emp t1 inner join s
14、cott.dept t2 on t1.deptno=t2.deptno where job=(2)select * from scott.emp t1 right join scott.dept t2 on t1.deptno=t2.deptno(3)select * from scott.emp t1 left join scott.dept t2 on t1.deptno=t2.deptno(4)用子查询实现:select * from scott.emp where deptno=(select deptno from scott.dept where dname=SALES)用连接查询
15、实现:select * from scott.emp t1 inner join scott.dept t2 on t1.deptno=t2.deptno where t2.dname=注意两种实现方式,在行和列上的变化。(5)简单自连接select t1.ename as 员工姓名,t2.ename 经理姓名 from scott.emp t1,scott.emp t2 where t1.mgr=t2.empno;(6)select t1.ename as 员工姓名,t2.ename 经理姓名 from scott.emp t1,scott.emp t2 where t1.mgr=t2.em
16、pno and t1.hiredatet2.hiredate(7)select t1.ename,t1.job,t1.deptno,t2.ename,t2.job,t2.deptno from scott.emp t1 cross join scott.emp t2 where t1.job=t2.job and t1.deptno t2.deptno(8)select t1.ename as 员工姓名,t2.ename 经理姓名 from scott.emp t1,scott.emp t2 where t1.mgr=t2.empno and t1.deptno=10;(9)select *
17、from scott.emp where sal2500 union select * from scott.emp where job=ANALYST(10)intersect(11)2500minus (12)(select avg(sal) from scott.emp)(13)select * from scott.emp where job=(select job from scott.emp where ename=SMITH(14)(select sal from scott.emp where ename=(15)select ename,sal from scott.emp
18、where salall(select sal from scott.emp where deptno=30)(16)select * from scott.emp where deptno in (select deptno from scott.emp group by deptno having count(*)5);(17)select * from scott.dept where deptno in(select deptno from scott.emp group by deptno having min(sal)2000)(18) 本题的关键是使用子查询作为数据源和查询的条件
19、,可以从最里层的子查询开始理解select * from scott.dept where deptno in (select deptno from (select deptno,count(*) as 人数 from scott.emp group by deptno) where 人数=(select max(人数) from(select deptno,count(*) as 人数 from scott.emp group by deptno);(19)select * from scott.dept where deptno in(select deptno from scott.e
20、mp group by deptno having count(*)=1)(20)本题关键是使用相关子查询做条件select * from scott.emp e where sal(select avg(sal) from scott.emp group by deptno having e.deptno=deptno);(21) 本题关键是使用两个子查询的结果进行内连接查询select * from(select * from scott.emp e where sal(select avg(sal) from scott.emp group by deptno having e.dept
21、no=deptno) t1 inner join(select avg(sal),deptno from scott.emp group by deptno) t2 on t1.deptno=t2.deptno);(22)select * from scott.dept where deptno in(select distinct deptno from scott.emp where empno in(select distinct mgr from scott.emp);(23)select * from scott.emp t1,scott.dept t2 where t1.deptn
22、o=t2.deptno and t1.deptno in(select deptno from scott.emp group by deptno having avg(sal)100;end loop;dbms_output.put_line(和是: |s);end;whlie循环实现:while i=100 loopfor循环实现:for i in 1.100 loop2.显示游标的for循环:cursor cur1 is select ename,sal from scott.emp;for rec in cur1 loopdbms_output.put_line(rec.ename|rec.sal);隐式游标的for循环:for rec in (select ename,sal from scott.emp) loopend
copyright@ 2008-2023 冰点文库 网站版权所有
经营许可证编号:鄂ICP备19020893号-2