oracle 11g第5章
Oracle 11g数据库基础教程第05章
ENCRYPT_IN_BACKUP
VARCHAR2(3) 指定备份数据库时是否加密。ON表示在表空间级别启动数据加密 功能;OFF表示在表空间级别关闭数据加密功能;NULL表示在表 空间级别未明确指定是否启动或关闭数据加密功能
【例5.1】
使用SYS用户以SYSDBA的身份登录到SQL Plus,执行下面的命令: SELECT * FROM V$TABLESPACE;
Oracle 11g数据库基础教程 (第2版)
授课教师: 职务:
第5章 数据库存储管理
课程描述
本章将重点介绍 Oracle数据库的存 储单元和物理文件 管理。Oracle数据 库的存储单元包括 表空间、段、区间 和数据块等。而数 据库的物理文件则 包括控制文件、数 据文件、临时文件、 重做日志文件和归 档重做日志文件等。
2.通过Oracle视图查看表空间信息
段 类 型 V$TABLESPACE DBA_TABLESPACES USER_TABLESPACES DBA_TABLESPACE_G ROUPS 说 明 控制文件中保存的所有表空间的名称和数量 所有表空间的属性和在线状态信息 所有用户可访问表空间的描述信息 所有表空间组及其所属的表空间信息 所有表空间中的区间信息 所有用户表空间中的区间信息 所有表空间中的空闲区间信息 所有用户表空间中的空闲区间信息 所有数据文件信息 所有临时文件信息 显示所有属于表空间的数据文件信息 显示所有属于临时表空间的临时文件信息
(2)查看表空间的属性信息
字段名 TABLESPACE_NAME BLOCK_SIZE 数据类型 VARCHAR2(30) NUMBER 表空间名称 表空间的数据块大小 说 明
INITIAL_EXTENT
Oracle11g基础入门理论
本章目标
理解Oracle 11g体系结构 掌握Oracle 11g数据库实例的创建 掌握Oracle 11g实例的启动与关闭 掌握Oracle网络连接配置
1. Oracle 11g 简介
1.1 Oracle 数据库系统的特点
Oracle数据库系统是美国Oracle公司(甲骨文)提供的以分布式数据库为 核心的一组软件产品
后台进程存在于操作系统中,在Oracle实例启动时自动启动
2.1 进程结构
服务器进程任务 解析并执行用户所提交的SQL语句 搜索SGA区的数据库缓存,决定是否读取数据文件,如果数据块不在SGA 区的数据库缓存中,则将其从数据文件中读入 将查询或执行后形成的数据返回给用户
后台进程任务 在内存和外存之间进行I/O操作 监视各个进程的状态 协调各个进程的任务 维护系统的性能 保证系统的可靠性能
数据文物件理文件
控制文件
数据文件是实际存储插入到数据库表中的实际数据的操作系统文件 数据文件的扩物展理名块 为“数*据物.d文理b件块f” 物理块
物理块
重做日志文件
重做日志文件
Oracle使用重做日志文件在故障发生之后重现当时的数据库操作,便 于数据库的恢复
重做日志文件的扩展名为“*.log”
Oracle数据库系统主要包含以下4个特点 支持大数据库、多用户、高性能的事务处理 提供了基于角色(ROLE)分工的安全保密管理 提供了新的分布式数据库能力 具有可移植性、可兼容性和可连接性
1.2 Oracle发展历史
1978年,Oracle 1诞生了,它是使用汇编语言开发的,但它的出现并没有引 起太多的关注
用户进程
用户进程
SGA
服务器进程
服务器进程
内存结构
ORACLE11g试题答案(陈冬亮)
目录第一章 Oracle 11g 介绍......................................... 错误!未定义书签。
第二章 ORACLE 11g 的体系结构................................... 错误!未定义书签。
第三章 ORACLE 11g 的数据库管理................................. 错误!未定义书签。
第四章 ORACLE 11g 的表空间管理................................. 错误!未定义书签。
第五章 ORACLE 11g 的表管理..................................... 错误!未定义书签。
第六章 ORACLE 11g 的数据查询................................... 错误!未定义书签。
第七章 ORACLE 数据的基本操作................................... 错误!未定义书签。
第八章索引 ................................................... 错误!未定义书签。
第九章视图 ................................................... 错误!未定义书签。
第十章 PL/SQL基础............................................. 错误!未定义书签。
第十一章存储过程与函数........................................ 错误!未定义书签。
第十二章触发器 ............................................... 错误!未定义书签。
第十三章游标 ................................................. 错误!未定义书签。
2020年智慧树知道网课《ORACLE快速入门》课后章节测试满分答案
第一章测试1【多选题】(10分)ORACLE的DBA日常工作有哪些任务A.ORACLE数据库应用架构设计B.ORACLE升级C.性能调优D.ORACLE安装2【多选题】(10分)数据库市场上主要分为哪几种类型的数据库A.关系型数据库B.NOSQL数据库C.ORACLE数据库D.NEWSQL数据库3【判断题】(10分)啤酒和尿片放在一起是数据挖掘的应用。
A.对B.错4【判断题】(10分)分布式数据库经常和并行数据库结合一起使用。
A.错B.对5【判断题】(10分)云数据库是云技术和数据库技术的结合。
A.对B.错第二章测试1【多选题】(10分)哪些操作系统可以安装ORACLE软件A.windows操作系统B.UNIX操作系统C.LINUX操作系统D.mac操作系统2【单选题】(10分)ORACLE11g中的g是什么意思A.互联网B.网格C.网络D.网址3【多选题】(10分)以下哪些是ORACLE的服务A.ORACLEDBCONSOLEORCLB.ORACLEORADB11G_HOME1TNSLISTENERC.ORACLEJOBSHEDULEORCLD.ORACLESERVICEORCL4【判断题】(10分)ORACLE的安装软件有32位安装包和64位安装包的区别。
A.对B.错5【判断题】(10分)我们可以通过数据库配置助手DBCA创建、删除、修改数据库。
A.错B.对第三章测试1【单选题】(10分)以下哪个选项是的A.sqlplus是客户端管理工具B.sqlplus就是sqlC.OEM是客户端管理工具D.sqlplus中除了可以输入sql语句外,还可以输入sqlplus的格式化语言2【单选题】(10分)在sqlplus中,用以下哪个命令可以查询表的结构A.describeB.showC.viewD.select3【单选题】(10分)以下哪个命令可以在sqlplus中执行某个文件中的sql命令A.editB.saveC.startD.sool4【判断题】(10分)使用edit命令修改缓冲区中最近一条命令。
oracle11g数据库管理与开发第5章答案.
第5章重做日志管理一、选择题1.Oracle数据库重做日志由(B)后台进程写入联机重做日志文件。
A.DBWRB.LGWRC.ARCnD.SMON2.重做日志缓冲区中的重做日志在(A、B)会被写入重做日志文件。
A.事务提交时B.重做日志缓冲区达到三分之一满,或者日志缓冲区内的日志量超过1MB时C.每3秒过后D.检查点发生时3.改变Oracle数据库归档模式时,需要把数据库启动到(B)状态。
A.NOMOUNTB.MOUNTC.OPEND.CLOSE二、简答题请简述Oracle数据库重做日志从产生到归档的过程。
答:从创建数据库时,重做日志文件产生,用户在执行数据库操作时,服务器进程把重做记录从用户内存空间拷贝到SGA,它们首先被缓存在SGA的重做日志缓冲区内,之后由ORACLE数据库的后台进程写入进程把他们写入联机重做日志文件中,一个数据库至少有两个重做日志文件,一组当前处于写入状态,另一组重做日志用于归档操作。
在oracle数据库运行在归档模式时,发三个部分日志切换后,归档进程(ARCn,n为归档进程号,它可以是0-9,a-t,oracle中可以启动多达30个归档进程)将把填充过的联机重做日志文件复制到指定的一个或者多个位置存储,为他们创建脱机副本,归档完成。
三、实训题1.练习把Oracle数据库从非归档模式修改为归档模式,之后创造条件让数据库立即归档,并检查归档是否成功。
(1)查看数据库的归档模式archive log list;(2)关闭数据库shutdown normal/immedtate;(3)吧数据库重新启动到mount状态startup mount;(4)把数据库修改为自动归档模式alter database archivelog;(5)打开数据库,供用户访问alter database open;(6)查看数据库的归档模式archive log list(7)让数据库立即自动归档archive system switch logfile(8)查看数据库是否归档archive log list;2.查看数据库当前重做日志文件组及成员的设置情况,之后为Oracle数据库添加一组重做日志。
Oracle 11g数据库管理与开发基础教程第5章
5.1.2 重做日志的相关概念
5. 归档进程与归档重做日志文件 Oracle数据库运行在归档模式时,发生日志切换后, 归档进程将把填充过的联机重做日志文件复制到指 定的一个或多个位置存储,为它们创建脱机副本, 这一过程被称作归档,重做日志文件的这些脱机副 本被称作归档重做日志文件。 归档分为自动归档和手工归档两种。启用自动归档后, 后台进程ARCn在日志切换后自动完成归档操作。采 用手工归档时,需调用下面SQL语句完成归档: ALTER SYSTEM ARCHIVE LOG ALL; ALTER SYSTEM ARCHIVE LOG NEXT;
archive log list SELECT group#, sequence# FROM v$log;
5.1.2 重做日志的相关概念
4. 重做日志文件组的状态 重做日志文件组的状态分为以下几种: ACTIVE:有效状态,指实例恢复时要用这组重做日 志文件; CURRENT:当前状态,指LGWR当前正在写入这组日 志文件; INACTIVRE:无效状态,实例恢复不再需要这组日 志文件; CLEARING:说明执行ALTER DATABASE CLEAR LOGFILE语句后,系统正在清除重做日志文件中的 内容; UNUSED:未使用过。新添加的重做日志文件组,或 者被清空之后的重做日志文件组处于该状态。
5.1.2 重做日志的相关概念
3. 日志切换与日志序列号 日志切换指LGWR停止写入一组联机重做日志文件,而开始写入 下一组重做日志文件这一操作。Oracle数据库以循环方式依 次使用各组重做日志文件。通常情况下,LGWR写满一组日志 文件后发生日志切换。但管理员也可在需要时执行下面命令 强制进行日志切换,或者设置ARCHIVE_LAG_TARGET参数要 求实例定期进行日志切换:
Oracle 11g完全手册
一.Window下关闭Oracle 11g正常在Windows下安全关闭Oracle数据库系统的步骤如下:1.从命令行下找到oracle的BIN目录,然后输入isqlplusctl stop命令停止isqlplus进程。
2.同样在BIN目录下,emctl stop dbconsole停止企业管理器的控制台进程。
3.同样在BIN目录下,lsnrctl stop停止监听进程。
4.在命令行下输入sqlplus /nolog , 然后conn / as sysdba连接到数据库shutdown immediate;====================================================================== select username,password from dba_users; --查看用户信息select username,account_status from dba_users; --查看用户是否解锁alter user scott account unlock; --解锁scott用户alter user scott account lock;--锁scott用户alter user scott identified by tiger; --为scott用户修改密码为tiger创建用户以及给表赋予权限:创建用户create user user_name identified by password;grant dba to user_name;查询表的权限grant select on gecs_law to user_name;select file_name from dba_data_files; --查看数据文件路径select name from v$controlfile; --查看控制文件路径select member from v$logfile; --查看日志文件路径====================================================================== Oracle关于shutdown、startup几个参数:shutdown有四个参数:normal、transactional、immediate、abort。
Oracle数据库基础及应用第05章SQLPlus命令
5.3.2 PROMPT命令
• 使用PROMPT命令可以在显示屏幕上输出指定的数据 和空行,这种输出方式非常有助于在脚本文件中向用 户传递相应的信息。
setsysytemoptionvalue选项描述setnumformatformat设置数字的默认显示格式setnulltext设置select语句返回null值时显示的字符串setpauseoffontext设置输出结果时是否滚动显示setpagesize14n设置每页打印的行数setrecsetwrappedeachoff显示或打印记录分隔符t1设置输出结果中列和列之间的空格数默set选项及说明续setspace1n设置输出结果中列和列之间的空格数默认值为10setsqlcasemixedlowerupper设置在执行sql命令之前是否转换大小写setsqlcontinuegt
设置输出结果中列和列之间的空格数,默 认值为10 设置在执行sql命令之前是否转换大小写 设置命令提示符 设置当前时间的显示 用于启动和关闭显示sql语句执行时间 设置是否在列标题下面添加分隔线
设置当一个数据项比当前行宽时,是否截 断数据项的显示
5.2.2 设置运行环境
• 在Oracle中怎么设置运行环境以及设置后的效果如何, 在这里可以通过具体的示例来进行演示。设置运行环 境中使用频率较高的操作如下所示。
第5章 SQLPlus命令
5.1使用SQL*P1us
• 在数据库系统中,可以使用两种方式 执行命令:
– 图形化工具
直观、简单、容易记忆;灵活性较差
– 使用各种命令
Oracle11g数据库基础教程-参考答案资料
SMON进程的主要功能包括:在实例启动时负责对数据库进行恢复;回收不再使用的临
时空间;将各个表空间的空闲碎片合并。
PMON进程的主要功能包括:负责恢复失败的用户进程或服务器进程,并且释放进程所
占用的资源; 清除非正常中断的用户进程留下的孤儿会话, 回退未提交的事务, 释放会话所
占用的锁、 SGA、 PGA 等资源;监控调度进程和服务器进程的状态,如果它们失败,则尝试
修改右侧对话框中
第 2 章 Oracle 数据库管理与开发工具
1.简答题
(1)
实现对 Oracle 运行环境的完全管理, 包括 Oracle 数据库、 Oracle 应用服务器、 HTTP 服务器等的管理;
实现对单个 Oracle 数据库的本地管理,包括系统监控、性能诊断与优化、 对象管理、存储管理、安全管理、作业管理、数据备份与恢复、数据移植等;
适合于工作组或部门级
的应用程序: 个人版数据库服务器只提供基本数据库管理功能和特性,
适合单用户的开发环
境,为用户提供开发测试平台。
(2)
常用数据库类型包括事务处理类、 数据仓库类以通用类型。 其中事务处理类型主要针对
具有大量并发用户连接, 并且用户主要执行简单事务处理的应用环境。 事务处理数据库的典 型应用有银行系统数据库、 Internet 电子商务数据库、证券交易系统数据库等。对于需要较 高的可用性和事务处理性能、 存在大量用户并行访问相同数据以及需要较高恢复性能的数据
Oracle 数据库物理结构包括数据文件、控制文件、重做日志文件、初始化参数文件、归 档文件、 口令文件等。 在控制文件中记录了当前数据库所有的数据文件的名称与位置、 日志文件的名称与位置,以及数据文件、重做日志文件的状态等。 (3)
Oracle11g教程第5章数据查询操作精品PPT课件
5.2 简单查询
选择列 1.选择所有列 2.选择指定列 3.计算列 4.使用别名
【例1-1】查询商品的所有信息。 SELECT * FROM SCOTT.Goods; 【例1-2】 网站管理人员在了解商品信息时只需要了解所有商品的商 品号、商品名称和商品单价。 SELECT g_ID, g_Name, g_Price FROM SCOTT.Goods 【例1-3】 在Goods表中存储有商品数量和商品单价,现在需要了解所 有商品的商品号、商品名称和商品总额。 SELECT g_ID, g_Name, g_Price*g_Number FROM Goods
2020/10/11 Orac le 数 据库 管理 与应 用实 例教 程
5.2 简单查询
选择行-条件查询-使用通配符
【例2-7】 需要了解所有商品中以“三星”两个字开头的商品的详细 信息。 SELECT * FROM Goods WHERE g_Name LIKE '三星%‘ 【例2-8】 需要了解姓“黄”且名字中只有两个汉字的会员的会员名、 真实姓名、电话和电子邮箱。 SELECT c_Name, c_TrueName, c_Phone, c_E-mail FROM Customers WHERE c_TrueName LIKE '黄_'
2020/10/11 Orac le 数 据库 管理 与应 用实 例教 程
5.2 简单查询
选择列
【例1-4】 要求了解所有商品的商品号、商品名称和总价值,但希望分 别以汉字标题商品号、商品名称和总价值表示g_ID、g_Name和 g_Price*g_Number。 SELECT g_ID 商品号, g_Name 商品名称, g_Price*g_Number 总价值 FROM SCOTT.Goods 【例1-5】显示所有会员的编号、姓名、性别和年龄 SELECT c_ID 编号, c_NAME 姓名, c_GENDER 性 别,TO_CHAR(SYSDATE,‘YYYY’) - TO_CHAR(c_BIRTH,‘YYYY’) AS 年 龄 FROM SCOTT.CUSTOMERS;
Oracle Database 11g Oracle Tuning Pack数据手册说明书
ORACLE TUNING PACKFEATURES• SQL Tuning Advisor• Automatic SQL TuningAdvisor• Real-Time SQL Monitoring• SQL Profiles• SQL Access Advisor• SQL Tuning Sets• Object Reorganization WizardBENEFITS• Comprehensive solution forapplication and SQL tuningthat eliminates need formanual tuning.• Provides automatic tuning ofSQL statements.• Enhances systemperformance and reliabilityand significantly lowersmanagement costs.Oracle Tuning Pack, an add-on pack for management of OracleDatabase 11g, offers an extremely cost effective and easy-to-use solution that automates the entire application tuning process. Enhancement of SQL performance is achieved through real-time monitoring and SQL Advisors that are seamlessly integrated with the Enterprise Manager, and together provide a comprehensive solution for automating the complex and time-consuming task of application tuning. For database administrators and application developers, application tuning is a critically important area and a considerable amount of their time is spent performing this very important function. A poorly tuned business application can potentially affect not just a few users but an entire business operation and for this reason companies invest significant resources to ensure smooth running of applications vital for their businesses. SQL Access Advisor The design of the database schema can have a big impact on the overall application performance. SQL Access Advisor, provides comprehensive advice on how to optimize schema design in order to maximize application performance. SQL Access and SQL Tuning Advisors, together, provide a complete solution for tuning database applications. The SQL Access Advisor accepts input from all possible sources of interest, such as the cursor cache, the Automatic Workload Repository (AWR), any user-defined workload, and will even generate a hypothetical workload if a schema contains dimensions or primary/foreign key relationships. It comprehensively analyzes the entire workload and provides recommendations to create new partitions or indexes if required, drop any unused indexes, create new materialized views and materialized view logs. Determining the optimal partitioning or indexing strategy for a particular workload is a complicated process that requires expertise and time. SQL Access Advisor considers the cost of insert/update/delete operations in addition to the queries on the workload and makes appropriate recommendations, accompanied by a quantifiable measure of expected performance gain as well as scripts needed to implement the recommendations. The SQL Access Advisor takes the mystery out of access structure design process. By automating this very critical function, SQL Access Advisor obviates the need for the error-prone, lengthy, and expensive manual tuning process. SQL Tuning Advisor Manual SQL tuning is a complex process that presents many challenges. It requires expertise in several areas, is very time consuming, and requires an intimateknowledge of the schema structures and the data usage model of the application. All these factors make manual SQL tuning a challenging and resource intensive task that is ultimately very expensive for businesses.SQL Tuning Advisor is Oracle’s answer to all the pitfalls and challenges of manual SQL tuning. It automates the SQL tuning process by comprehensively exploring all the possible ways of tuning a SQL statement. The analysis and tuning is performed by the database engine’s significantly enhanced query optimizer. Four types of analysis are performed by the SQL Tuning Advisor:• Statistics Analysis: In this analysis objects with stale or missing statistics are identified and appropriate recommendations are made to remedy the problem.• SQL Profiling: This feature, introduced in Oracle Database 10g, revolutionizes the approach to SQL tuning. SQL Profiling tunes SQL statements withoutrequiring any change to the application code.• Access Path Analysis: In this analysis new indexes that can significantlyenhance query performance are identified and recommended.The output of this analysis is in the form of recommendations, along with a rationale for each recommendation and its expected performance benefit.The SQL Tuning Advisor offers a powerful, intuitive, and user-friendly way for performing SQL tuning. Tuning of SQL statements no longer has to be the domain of experts. Oracle has built a tuning expert inside the database engine to perform this very important function for the database administrators in a fraction of the time and cost needed to carry out the same task manually.Automatic SQL Tuning AdvisorThe SQL Tuning Advisor also runs in automatic mode. In this mode, the advisor runs automatically during system maintenance windows as a maintenance task. During each run, the advisor selects high-load SQL queries in the system, and generates recommendations on how to tune them.Figure 1: Automatic SQL Tuning Results SummaryThe Automatic SQL Tuning Advisor can be configured to auto-implement SQL Profile recommendations. If you enable automatic implementation, the advisor will create SQL Profiles for only those SQL statements where performance improvement would be at least threefold. Other types of recommendations such as to create newindexes, refresh optimizer statistics or restructure SQL can only be implemented manually. DML statements are not considered for tuning by the Automatic SQL Tuning Advisor.You can view a summary of the automatic SQL tuning results over a specified period, and can view a detailed report on recommendations made for all SQL statements processed. The recommendations can then be implemented selectively by a manual process. You can also view the recommendations that were automatically implemented.Real-time SQL MonitoringThe first step in SQL tuning is identifying poor SQL that is consuming excessive system resources. Traditionally, DBAs have always struggled with long-running SQL in live production environments because they never had the tools to figure out if the long-running query was moments away from completion or a run-away query that could take an inordinate amount of time to complete. Real-Time SQL Monitoring introduced in Oracle Database 11g provides the fastest and easiest way to identify and fix performance problems with long running SQL statements. Live visual displays track the details of SQL execution using new, fine-grained SQL statistics that are updated automatically at no cost to the performance of production systems.By default, SQL monitoring is automatically started when a SQL statement runs parallel, or when it has consumed at least 5 seconds of CPU or IO time in a single execution. Once monitoring is initiated, an entry is added to performance views. This entry tracks row source information at each step of the execution collecting key performance metrics, including the elapsed time, CPU time, number of reads and writes, I/O wait time and various other wait times. This allows the DBAs to decide whether to let the query complete or terminate the query.Figure 1: Real Time SQL MonitoringReal Time SQL Monitoring has been enhanced in Oracle Database 11g Release 2 to support execution plans that are being executed in part by the Oracle Databasemachine, Exadata. DBAs now have a powerful tool to track complex execution plans, identify poor indexing mechanisms and identify skew in parallel queries– all in real time. Object Reorganization Wizard Oracle Tuning Pack also provides the ability to reorganize objects. Managing the space usage of your tablespaces efficiently by removing wasted space is not only a good space management practice but it also enhances performance by reducing unnecessary disk I/Os. Reorganization is used for: 1) rebuilding indexes and tables that are fragmented, 2) relocating objects to another tablespace, and 3) recreating objects with optimal storage attributes. Contact Us For more information about [insert product name], please visit or call +1.800.ORACLE1 to speak to an Oracle representative. Copyright © 2010, Oracle and/or its affiliates. All rights reserved. This document is provided for information purposes only and the contents hereof are subject to change without notice. This document is not warranted to be error-free, nor subject to any other warranties or conditions, whether expressed orally or implied in law, including implied warranties and conditions of merchantability or fitness for a particular purpose. We specifically disclaim any liability with respect to this document and no contractual obligations are formed either directly or indirectly by this document. This document may not be reproduced or transmitted in any form or by any means, electronic or mechanical, for any purpose, without our prior written permission. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners. AMD, Opteron, the AMD logo, and the AMD Opteron logo are trademarks or registered trademarks of Advanced Micro Devices. Intel and Intel Xeon are trademarks or registered trademarks of Intel Corporation. All SPARC trademarks are used under license and are trademarks or registered trademarks of SPARC International, Inc. UNIX is a registered trademark licensed through X/Open Company, Ltd. 0110Oracle Tuning Pack 11g delivers maximum benefits when used with the following Oracle products:RELATED PRODUCTS • Oracle Diagnostics Pack • Oracle Configuration Management Pack • Oracle Provisioning Pack • Oracle Database Change Management Pack • Oracle Real Application Testing Option。
Oracle 11g从入门到精通(第2版)
2 Oracle 11g体系结构 (视频讲解: 89分钟) 2.3 物理存储结构
2.3.1 数据文件 2.3.2 控制文件 2.3.3 日志文件 2.3.4 服务器参数文件 2.3.5 密码文件、警告文件和跟踪文件
2 Oracle 11g体系结构 (视频 讲解:89分钟) 2.4 Oracle 11g服务器结构
5.1 PL/SQL简介
5.1.1 PL/SQL块结构 5.1.2 代码注释和标示符 5.1.3 文本
5 PL/SQL编程 (视频 讲解:102分钟) 5.2 数据类型、变量和常量
5.2.1 基本数据类型 5.2.2 特殊数据类型 5.2.3 定义变量和常量 5.2.4 PL/SQL表达式
3.4 格式化查询结果
3.4.1 COLUMN命令 3.4.2 TTITLE和BTITLE命令
4 SQL语言基础 (视频讲解:189分钟)
4.1 SQL语 言简介
4.2 用 户模式
4.3 检 索数据
4.4 Oracle 常用系统函 数
4.5 子 查询的 用法
4.6 操 作数据 库
4 SQL语言基础 (视频讲解: 189分钟)
4 SQL语言基础 (视频 讲解:189分钟) 4.5 子查询的用法
4.5.1 什么是子查询 4.5.2 单行子查询 4.5.3 多行子查询 4.5.4 关联子查询
4 SQL语言基础 (视频讲 解:189分钟)
4.6 操作数据库
4.6.1 插入数据(INSERT语句) 4.6.2 更新数据(UPDATE语句) 4.6.3 删除数据(DELETE语句和TRUNCATE语 句)
2.6 小结
2 Oracle 11g体系结构 (视频讲解:89分钟)
Oracle_11g日常操作与维护手册
Oracle 11g日常操作与维护手册拟制:数据库TMG 日期:20011-2-14 审核:日期:批准:日期:目录第1章文档说明 (5)第2章CRS的管理 (5)2.1 RAC状态检查 (5)2.1.1检查守护进程状态 (5)2.1.2检查资源状态 (5)2.2 手工启动与关闭RAC (6)2.3 OCR的管理 (6)2.4 VOTING DISK的管理 (8)2.5 CSS管理 (9)2.6 管理工具SRVCTL (9)2.6.1管理实例 (9)2.6.2管理监听程序 (9)2.6.3管理ASM (10)2.6.4管理service (10)2.7 修改RAC的IP及VIP (11)2.7.1修改外网IP及心跳IP (11)2.7.2修改VIP (11)2.7.3查看与删除IP (12)第3章ASM的管理 (13)3.1 管理DG (13)3.1.1建立与扩充disk group (13)3.1.2 mount与unmount的命令 (14)3.1.3删除disk group (14)3.1.4增加DISK的total_mb (14)3.1.5 DG的属性-AU大小 (14)3.1.6 DG的属性-离线删除时间 (15)3.1.7 DG的属性-兼容版本 (15)3.1.8向ASM中添加disk的完整步骤 (16)3.2 ASMCMD (17)3.2.1 ASMCMD常用命令 (17)3.2.2复制ASM文件 (18)3.2.3命令lsdg (18)3.2.4元数据备份与恢复 (18)3.3 ASM磁盘头信息备份与恢复 (19)3.4 ASM常用视图 (20)3.4.1视图V$ASM_DISKGROUP (20)3.4.2视图V$ASM_DISK (21)3.5 常用方法 (22)3.5.1如何确定ASM实例的编号 (22)3.5.2查询DG-RAW-磁盘的对应关系 (22)第4章数据库管理 (24)4.1 参数文件管理 (24)4.2 表空间管理 (25)4.2.1表空间自动扩张 (25)4.2.2表空间更名 (26)4.2.3表空间的数据文件更名 (26)4.2.4缺省表空间 (26)4.2.5表空间删除 (27)4.2.6 UNDO表空间 (27)4.2.7 TEMP表空间 (27)4.3 重做日志文件管理 (27)4.3.1增加REDO日志组 (27)4.3.2删除日志组 (28)4.3.3日志切换 (28)4.3.4日志清理 (28)4.3.5重做日志切换次数查询 (28)4.4 归档模式 (29)4.4.1单实例数据库修改为归档模式的方法 (29)4.4.2 RAC数据库修改为归档模式的方法 (29)4.4.3归档路径 (30)4.5 重建控制文件 (31)4.6 内存参数管理 (32)4.6.1 Oracle内存管理发展阶段 (32)4.6.2自动内存管理AMM (32)4.6.3自动共享内存管理ASMM (33)4.6.4自动PGA管理 (33)4.7 其他管理内容 (33)4.7.1数据库版本查看 (33)4.7.2字符集 (34)4.7.3创建密码文件 (34)4.7.4关闭审计功能 (34)4.7.5帐号管理 (34)4.7.6 profile管理 (35)第1章文档说明本文档描述了Oracle11g中常见的维护和管理方法,包括CRS、ASM、数据库等。
oracle11g课程设计
oracle11g课程设计一、课程目标知识目标:1. 理解Oracle 11g数据库的基本概念和体系结构;2. 掌握Oracle 11g数据库的安装和配置方法;3. 学会使用SQL语言进行数据查询、插入、更新和删除操作;4. 掌握Oracle 11g数据库的表、索引、视图和存储过程的创建与管理;5. 了解数据库的安全性和事务处理。
技能目标:1. 能够独立完成Oracle 11g数据库的安装和配置;2. 能够运用SQL语言实现数据的基本操作;3. 能够设计和实现简单的数据库表、索引、视图和存储过程;4. 能够进行数据库的安全性设置和事务处理。
情感态度价值观目标:1. 培养学生对数据库技术的兴趣,激发学习积极性;2. 培养学生良好的团队合作精神和沟通能力;3. 增强学生的数据库安全意识,培养责任感;4. 使学生认识到数据库技术在实际应用中的重要性,提高职业素养。
课程性质:本课程为实践性较强的课程,注重理论与实践相结合,培养学生的实际操作能力。
学生特点:学生具备一定的计算机基础和编程能力,对数据库技术有一定了解,但实践经验不足。
教学要求:教师应注重引导学生主动学习,采用案例教学和任务驱动教学,提高学生的实践操作能力。
同时,关注学生的学习进度和情感需求,及时调整教学策略,确保教学效果。
通过本课程的学习,使学生能够掌握Oracle 11g数据库的基本知识和技能,为以后从事相关工作打下坚实基础。
二、教学内容1. Oracle 11g数据库概述:介绍数据库的基本概念、Oracle 11g数据库的特点和体系结构,对应教材第一章。
- 数据库基本概念- Oracle 11g体系结构- Oracle 11g新特性2. Oracle 11g数据库安装与配置:讲解Oracle 11g数据库的安装步骤、配置方法,对应教材第二章。
- 安装Oracle 11g数据库- 配置网络监听器- 创建数据库实例3. SQL语言基础:学习SQL语言的基本语法和用法,进行数据查询、插入、更新和删除操作,对应教材第三章。
Oracle HTTP Server 11g R1 配置手册说明书
Oracle HTTP Server 11g R1 Configuration for FLEXCUBEOracle FLEXCUBERelease 12.4.0.0.0[May] [2017]Table of Contents1.PURPOSE (3)2.INTRODUCTION TO ORACLE HTTP SERVER (OHS) (3)2.1HTTP L ISTENER (3)2.2M ODULES (MODS) (3)3.INSTALLATION OF OHS 11G (4)4.CONFIGURE ORACLE HTTP SERVER INFRONT OF WEBLOGIC SERVER (11)4.1F OR W EB L OGIC IN SINGLE INSTANCE (11)4.2F OR W EBLOGIC INSTANCES IN CLUSTER (12)5.ENABLE “WEBLOGIC PLU G-IN ENABLED” FLAG I N WEBLOGIC (13)PRESSION RULE SETTING (13)6.1L OADING MOD_DEFLATE (13)6.2C ONFIGURING FILE TYPES (14)6.3HTTPD.CONF FILE CHANGES (14)7.CONFIGURING SSL FOR ORACLE HTTP SERVER (16)7.1SSL CONFIGURATION FOR I NBOUND R EQUEST TO O RACLE HTTP S ERVER (16)7.1.1Create a new Wallet and import Certificate (16)7.1.2Configuring Wallet in ssl.conf file (20)7.2C ONFIGURING SSL BETWEEN O RACLE HTTP S ERVER AND O RACLE W EBLOGIC S ERVER (21)7.2.1Turn off KeepAliveEnabled (21)7.2.2To enable one-way SSL (21)7.2.3To enable two-way SSL (22)8.SAMPLE CONFIGURATION FILES (23)9.STARTING, STOPPING, AND RESTARTING ORACLE HTTP SERVER (23)9.1S TART (23)9.2S TOP (23)9.3R ESTART (23)10.TEST THE APPLICATION (24)11.SERVER LOGS LOCATION (24)12.REFERENCES (24)1. PurposeThe objective of this document is to explain the installation and configuration of Oracle HTTP Server 11g R1(11.1.1.6.0). This includes setting up of server details, configuration of compression rules and enabling SSL.2. Introduction to Oracle HTTP Server (OHS)Oracle HTTP Server is the Web server component for Oracle Fusion Middleware. It is based on Apache web server, and includes all base Apache modules and modules developed specifically by Oracle. It provides a HTTP listener for Oracle WebLogic Server and the framework for hosting static pages, dynamic pages, and applications over the Web. Key aspects of Oracle HTTP Server are its technology, its serving of both static and dynamic content and its integration with both Oracle and non-Oracle products.Oracle HTTP Server consists of several components that run within the same process. These components provide the extensive list of features that Oracle HTTP Server offers when handling client requests.Following are the major components:2.1 HTTP ListenerOracle HTTP Server is based on an Apache HTTP listener to serve client requests. An HTTP server listener handles incoming requests and routes them to the appropriate processing utility.2.2 Modules (mods)Modules extend the basic functionality of Oracle HTTP Server, and support integration between Oracle HTTP Server and other Oracle Fusion Middleware components. There are modules developed specifically by Oracle for Oracle HTTP Server. Ex: mod_wl_ohs, mod_plsqlOracle HTTP Server also includes the base Apache and third-party modules out-of-the-box.These modules are not developed by Oracle. Ex: mod_proxy, mod_perl3. Installation of OHS 11gInvoke the setup exe to start the installationSelect Skip Software UpdatesSelect Install and ConfigureSelect only Oracle HTTP ServerEnter the required OHS instance and component namesThis completes the installation of Oracle HTTP Server with <Instance> and <component>. Example: Instance is instance1 and component is ohs1.If you would like to change the port after the installation(OHS Listen Port) edit$ORACLE_INSTANCE/config/OHS/<component_name>/httpd.conf and change the listen port.NOTE: This port is for http protocol and not for https.4. Configure Oracle HTTP Server infront of Weblogic ServerIn Oracle HTTP Server requests from Oracle HTTP Server to Weblogic server are proxied usingmod_wl_ohs module. This configuration file needs to be modified to include the Weblogic server and port details.mod_wl_ohs.conf file is located at${ORACLE_INSTANCE}/config/OHS/{COMPONENT_NAME}/mod_wl_ohs.confAdd the below directives to mod_wl_ohs.conf file.4.1 For WebLogic in single instance<Location /<<context/url>> >SetHandler weblogic-handlerWebLogicHost <<server name>>WeblogicPort <<port>></Location>Example:<Location /FCJNeoWeb>SetHandler weblogic-handlerWebLogicHost wlserver1WeblogicPort 7707</Location>This will forward /FCJNeoWeb from HTTP server to /FCJNeoWeb on WebLogic Server wlserver1: 77074.2 For Weblogic instances in cluster<Location /<<context/url>> >SetHandler weblogic-handlerWebLogicCluster <server1>:<port1>,<server2>:<port2></Location>Example<Location / FCJNeoWeb >SetHandler weblogic-handlerWebLogicCluster wlserver1:7010, wlserver2:7010</Location>This will forward /FCJNeoWeb from HTTP server to /FCJNeoWeb on WebLogic Cluster wlserver1:7010 and wlserver2:70105.Enable “WebLogic Plug-In Enabled” flag in weblogicThis flag needs to be enabled in weblogic if it is accessed through proxy plugins. When the WebLogic plugin is enabled, a call to getRemoteAddr will return the address of the browser client from the proprietary WL-Proxy-Client-IP header instead of the web server.a. Plugin flag at managed server leveli. Click on ‘Environment’- > 'Servers' -> '<ManagedServer>' -> 'General' -> 'Advanced'ii. Check the 'WebLogic Plug-In Enabled' box.iii. Click 'Save'iv. Restart the Server.b. Plugin flag at domain levelv. Click on <Domain> -> 'Web Applications'vi. Check the 'WebLogic Plug-In Enabled' box.vii. Click 'Save'viii. Restart the server.6. Compression rule settingContent compression in Oracle HTTP Server is done using mod_deflate. This can compress HTML, text or XML files to approx. 20 - 30% of their original sizes, thus saving on server traffic. However, compressing files causes a slightly higher load on the server, but clients' connection times to server is reduced.6.1 Loading mod_deflatemod_deflate is used for compression in OHS and this is installed in Oracle HTTP Server under location "${ORACLE_HOME}/OHS/modules/mod_deflate.so"But it might not be loaded.To load the file add the below directive in mod_wl_ohs.conf fileLoadModule deflate_module "${ORACLE_HOME}/OHS/modules/mod_deflate.so"6.2 Configuring file typesmod_deflate also requires to specify which type files are going to be compressed.In the LOCATION section of mod_wl_ohs.conf file add the below entries.AddOutputFilterByType DEFLATE text/plainAddOutputFilterByType DEFLATE text/xmlAddOutputFilterByType DEFLATE application/xhtml+xmlAddOutputFilterByType DEFLATE text/cssAddOutputFilterByType DEFLATE application/xmlAddOutputFilterByType DEFLATE application/x-javascriptAddOutputFilterByType DEFLATE text/htmlSetOutputFilter DEFLATEImages are supposed to be in a compressed format, and therefore are bypassed by mod_deflate.6.3 httpd.conf file changesThis is a server configuration file which typically contains directives that affect how the server runs, such as user and group IDs it should use, and location of other files. Cross check the existence of mod_wl_ohs.conf include in httpd.conf file.httpd.conf file is present under location“${ORACLE_INSTANCE}/config/OHS/{COMPONENT_NAME}/httpd.conf”In this file cross check for the below entryinclude "${ORACLE_INSTANCE}/config/OHS/${COMPONENT_NAME}/mod_wl_ohs.conf"If above include entry is not present, then add the above include section.7. Configuring SSL for Oracle HTTP ServerSecure Sockets Layer (SSL) is required to run any Web site securely. Secure Sockets Layer (SSL) is an encrypted communication protocol that is designed to securely send messages across the Internet.Reading of “SSL_Configuration on Weblogic” document provide d as part of FCUBS installation isrecommended before proceeding with further setup.In Oracle HTTP server, SSL configuration can be done between1. Browser to Oracle HTTP Server(Mandatory)2. Oracle HTTP Server to Oracle Weblogic Server(If required)7.1 SSL configuration for Inbound Request to Oracle HTTP ServerPerform these tasks to enable and configure SSL between browser and Oracle HTTP Server.1. Obtain a certificate from CA or create a self signed certificate.2. Create an Oracle Wallet which contains the above SSL Certificate. The default wallet that isautomatically installed with Oracle HTTP Server is for testing purposes only. The default wallet is located in "${ORACLE_INSTANCE}/config/OHS/${COMPONENT_NAME}/keystores/default"3. Configuring Wallet in ssl.conf file7.1.1 Create a new Wallet and import Certificate1. Go to the \Oracle_WT1\bin\launch.exe, this will launch your wallet manager2. Click on Create new and then click no option.3. Enter the wallet password and click on OK, this will create a new wallet.4. Not it will ask for certificate request creation, Click on NO to proceed5. Right click on trusted certificates and then import trusted certificate.6. Browse to the folder where certificate is stored and click on Open7. Click on Save Wallet button on the left side navigation and save the wallet either to defaultlocation("${ORACLE_INSTANCE}/config/OHS/${COMPONENT_NAME}/keystores/default") or folder of your choice.8. Click on Wallet tab and enable Auto Login7.1.2 Configuring Wallet in ssl.conf fileIn ssl.conf file the newly created wallet need to updated. This file is located under folder"${ORACLE_INSTANCE}/config/OHS/${COMPONENT_NAME}/1. Change the SSLWallet directive to point to the location of new wallet created.SSLWallet "${ORACLE_INSTANCE}/config/${COMPONENT_TYPE}/${COMPONENT_NAME}/keystores/"2. Change the Listen port number in ssl.conf file to the SSL enabled port, by default the value is 44437.2 Configuring SSL between Oracle HTTP Server and Oracle Weblogic ServerSSL for outbound requests from Oracle HTTP Server are configured in mod_wl_ohs.Refer to “SSL_Configura tion on Weblogic” document for weblogic server setting mentioned in below section.7.2.1 Turn off KeepAliveEnabledThe below parameter in mod_wl_ohs should be turned off, by default it is on. Add the below directive under LOCATION section of mod_wl_ohs fileKeepAliveEnabled OFF7.2.2 To enable one-way SSL1. Generate a custom keystore identity.jks for Weblogic Server containing a certificate.2. At Identity section in Keystores tab in weblogic Admin Console for server seta. The custom trust store with the identity.jks file locationb. The keystore type as JKSc. The passphrase used to created the keystore3. Copy the certificate to Oracle HTTP Server and import the new certificate into OHS wallet as a trustedcertificate.4. Add following new directive in mod_wl_ohs.conf to point to the wallet locationWlSSLWallet "${ORACLE_INSTANCE}/config/OHS/{COMPONENT_NAME}/keystores/default"5. Change the port in mod_wl_ohs file to point to SSL port of Weblogic server.6. Restart both Weblogic Server and Oracle HTTP Server7.2.3 To enable two-way SSL1. Perform one-way SSL configuration steps2. Generate a new trust store, trust.jks for Weblogic server3. Keystore created for one-way SSL could be used, but it is recommended to create a separate truststore4. Export the user certificate from Oracle HTTP Server wallet, and import it into truststore created above5. At Trust section in Keystores tab in Weblogic Admin Console for the server seta. The custom trust store with the trust.jks file locationb. The keystore type as JKSc. The passphrase used to created the keystore6. Under the SSL tabEnsure trusted CA is set as from Custom Trust Keystore.7. Restart Weblogic Server8. Sample Configuration Fileshttpd.conf mod_wl_ohs.conf ssl.conf9. Starting, Stopping, and Restarting Oracle HTTP ServerNavigate to the below location in command prompt ${ORACLE_INSTANCE}/bin/ and run below commands 9.1 Startopmnctl startproc ias-component={COMPONENT_NAME}Example: opmnctl startproc ias-component=ohs19.2 Stopopmnctl stopproc ias-component={COMPONENT_NAME}Example: opmnctl stopproc ias-component=ohs19.3 Restartopmnctl restartproc ias-component={COMPONENT_NAME}Example: opmnctl restartproc ias-component=ohs110. Test the applicationTest the application deployed on Weblogic using Oracle HTTP Server after restarting both the oracle http server and weblogic serverhttps://ohs_servername:ohs_https_port/<<context/url>>http://ohs_servername:ohs_http_port/<<context/url>>ohs_servername: server on which OHS is deployedohs_https_port: port number mentioned against LISTEN directive in SSL.conf fileohs_http_port: port number mentioned against LISTEN directive in httpd.conf fileExample:https://localhost:4443/FCJNeoWeb/welcome.jspOrhttp://localhost:7777/FCJNeoWeb/welcome.jsp11. Server Logs LocationOracle HTTP Server Logs are generated under folder${ORACLE_INSTANCE}/diagnostics/logs/OHS/{COMPONENT_NAME}/12. ReferencesSSL_Configuration.doc for Weblogic provided as part of FCUBS installation./cd/E16764_01/web.1111/e10144/under_mods.htm/cd/E25054_01/core.1111/e10105/sslconfig.htmOracle_HTTP_Server_Configuration[May] [2017]Version 12.4.0.0.0Oracle Financial Services Software LimitedOracle ParkOff Western Express HighwayGoregaon (East)Mumbai, Maharashtra 400 063IndiaWorldwide Inquiries:Phone: +91 22 6718 3000Fax:+91 22 6718 3001/financialservices/Copyright © 2007, 2017, Oracle and/or its affiliates. All rights reserved.Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners. U.S. GOVERNMENT END USERS: Oracle programs, including any operating system, integrated software, any programs installed on the hardware, and/or documentation, delivered to U.S. Government end users are "commercial computer software" pursuant to the applicable Federal Acquisition Regulation and agency-specific supplemental regulations. As such, use, duplication, disclosure, modification, and adaptation of the programs, including any operating system, integrated software, any programs installed on the hardware, and/or documentation, shall be subject to license terms and license restrictions applicable to the programs. No other rights are granted to the U.S. Government.This software or hardware is developed for general use in a variety of information management applications. It is not developed or intended for use in any inherently dangerous applications, including applications that may create a risk of personal injury. If you use this software or hardware in dangerous applications, then you shall be responsible to take all appropriate failsafe, backup, redundancy, and other measures to ensure its safe use. Oracle Corporation and its affiliates disclaim any liability for any damages caused by use of this software or hardware in dangerous applications.This software and related documentation are provided under a license agreement containing restrictions on use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, publish or display any part, in any form, or by any means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is prohibited.The information contained herein is subject to change without notice and is not warranted to be error-free. If you find any errors, please report them to us in writing.This software or hardware and documentation may provide access to or information on content, products and services from third parties. Oracle Corporation and its affiliates are not responsible for and expressly disclaim all warranties of any kind with respect to third-party content, products, and services. Oracle Corporation and its affiliates will not be responsible for any loss, costs, or damages incurred due to your access to or use of third-party content, products, or services.。
最新Oracle11g数据库基础教程课后习题答案
最新Oracle11g数据库基础教程课后习题答案Oracle11g数据库基础教程参考答案第5章数据库存储设置与管理P70.实训题(8)为USERS表空间添加一个数据文件,文件名为USERS05.DBF,大小为5 0MB。
ALTER TABLESPACE USERS ADD DATAFILE‘D:\ORACLE\ORADATA\ORCL\%users05.dbf’ SIZE 50M;(9)为EXAMPLE表空间添加一个数据文件,文件名为example05.dbf,大小为20MB。
ALTER TABLESPACE EXAMPLEADD DATAFILE ‘D:\ORACLE\ORADATA\ORCL\example05.dbf’ SIZE 20M;(10)修改USERS表空间中的userdata05.dbf为自动扩展方式,每次扩展5MB,最大为100MB。
ALTER DATABASE DATAFILE‘D:\ORACLE\ORADATA\ORCL\%userdata05.dbf’ AUTOEXTEND ON NEXT 5M MAXSIZE 100M;(14)为数据库添加一个重做日志文件组,组内包含两个成员文件,分别为redo5a.log和redo5b.log,大小分别为5MB。
ALTER DATABASE ADD LOGFILE GROUP 5(‘D:\ORACLE\ORADATA\ORCL\redo5a.log’,‘D:\ORACLE\ORADATA\ORCL\redo5b.log’)SIZE 5M;(15)为新建的重做日志文件组添加一个成员文件,名称为redo5c.log。
ALTER DATABASE ADD LOGFILE MEMBER ‘D:\ORACLE\ORADATA\ORCL\redo5c.log’ TO GROUP 5;(16)将数据库设置为归档模式,并采用自动归档方式。
SHUTDOWN IMMEDIATE STARTUP MOUNTALTER DATABASE ARCHIVELOG;ALTER DATABASE OPEN;ALTER SYSTEM ARCHIVE LOG START(8)ALTER TABLESPACE USERSADD DATAFILE ‘D:\ORACLE\ORADATA\ORCL\userdata05.dbf’ SIZE 50M’;(9)ALTER TABLESPACE EXAMPLEADD DATAFILE ‘D:\ORACLE\ORADATA\ORCL\example05.dbf’ SIZE 20M’;(10)ALTER DATABASE DATAFILE ‘D:\ORACLE\ORADATA\ORCL\us erdata05.dbf’ AUTOEXTEND ON NEXT 5M MAXSIZE 100M;(14)ALTER DATABASE ADD LOGFILE GROUP 5(‘D:\ORACLE\ORADATA\ORCL\redo05a.log’,’D:\ORACLE\ORADATA\ORCL\redo05b.log’)SIZE 5M;(15)ALTER DATABASE ADD LOGFILE MEMBER‘D:\ORACLE\ORADATA\ORCL\redo05c.log’ TO GR OUP 5;(16)SHUTDOWN IMMEDIATESTARTUP MOUNTALTER DATABASE ARCHIVELOG;ALTER DATABASE OPEN;ALTER SYSTEM ARCHIVE LOG START第6章数据库对象的创建与管理2.实训题Create table exer_class(CNO number(2) primary key,CNAME varchar2(20),NUM number(3))Create table exer_student(SNO number(4) primary key,SNAME varchar2(10) unique,SAGE number,SEX char(2),CNO number(2))(3)Alter table exer_student add constraint ck_sage check (sage>0 and sage<=100);(4)alter table exer_student add constraint ck_stu check(sex='M' or sex='F')modify sex default 'M'(5)Create unique index ind_cname on exer_class(cname);(6)Create view s_c asSelectsno,sname,sage,sex,/doc/3612353519.html,o,cn ame,numFrom exer_class c join exer_student sOn/doc/3612353519.html,o=/doc /3612353519.html,o;Create sequence sequ1 start with 100000001;(8)create table exer_student_range(sno number(4) primary key,sname varchar2(10),sage number,sex char(2),cno number(2))partition by range(sage)(partition part1 values less than(20) tablespace example,partition part2 values less than(30) tablespace orcltbs1,partition part3 values less than(maxvalue) tablespace orcltbs2)(9)create table exer_student_list(sno number(4) primary key,sname varchar2(10),sage number,sex char(2),cno number(2))partition by list(sex)(partition man values('M') tablespace orcltbs1,partition woman values('F') tablespace orcltbs2)(10)Create index ind on exer_student_range(sno) local;第9章PL/SQL语言基础1.实训题(1)declarecursor c_emp is select * from employees;beginfor v_emp in c_emp loopdbms_output.put_line(v_emp.first_name||''||v_/doc/3612353519.html,st_name||' '||v_emp.employee_id||' '||v_emp.salary||' '||v_emp.department_id); end loop;end;(2)declarev_avgsal employees.salary%type;beginfor v_emp in (select * from employees) loopselect avg(salary) into v_avgsal from employeeswhere department_id=v_emp.department_id;if v_emp.salary>v_avgsal thendbms_output.put_line(v_emp.first_name||''||v_/doc/3612353519.html,st_name||' '|| v_emp.employee_id||' '||v_emp.salary||' '||v_emp.department_id);end if;end loop;end;(3)declarecursor c_emp isselect e.employee_id eid,/doc/3612353519.html,st_name ename,e.department_id edid,m.employee_id mid,/doc/3612353519.html,st_name mname from employees e join employees mon e.manager_id=m.employee_id;v_emp c_emp%rowtype;beginopen c_emp;loopfetch c_emp into v_emp;exit when c_emp%notfound;dbms_output.put_line(v_emp.eid||' '||v_emp.ename||' '||v_emp.edid||' '||v_emp.mid||' '||v_emp.mname);end loop;close c_emp;end;(4)declarev_emp employees%rowtype;beginselect * into v_emp from employees where last_name='Smith';dbms_output.put_line(v_emp.employee_id||' '||v_emp.first_name||''||v_/doc/3612353519.html,st_name||' '|| v_emp.salary||' '||v_emp.department_id); exceptionwhen no_data_found theninsert into employees(employee_id,last_name,salary,email,hire_date,job_id,department_id)values(2010,'Smith',7500,'smith@/doc/361 2353519.html,',to_date('2000-10-5','yyyy-mm-dd'),'AD_VP',50);when too_many_rows thenfor v_emp in(select * from employees where last_name='Smith')loopdbms_output.put_line(v_emp.employee_id||' '||v_emp.first_name||''||v_/doc/3612353519.html,st_name||' '||v_emp.salary||' '||v_emp.department_id);end loop;end;第10章PL/SQL程序设计(1)创建一个存储过程,以员工号为参数,输出该员工的工资。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
12
5.1.3 管理表中的列
为表增加列的语法形式如下:
【例 5.2】为表 person 增加emailADD 列 column_name ALTER TABLE table_name ALTER TABLE person ADD email VARCHAR2(20); data_type;
1.增加列
5.1.1 数据类型
BLOB BFILE 二进制大对象类型。最大存储128T。 指向二进制文件的定位器。该二进制文件 保存在数据库外部的操作系统中,文件最大 为4GB。 行标识符,表中行的物理地址的伪列类型。 该数据类型主要用于由ROWID伪列返回的值。 行标识符,表示索引化表中行的逻辑地址。 可 变 长 度 字 符 串 , 最 大 长 度 为 2GB 。 在 Oracle 11g中该类型已经被CLOB和NCLOB替 代,仍然提供该类型是为了向后兼容。 可变长度的二进制数据,最大长度为2000 字节。 可变长度的二进制数据,最大长度为2GB 。 在Oracle 11g中该类型已经被BLOB替代,仍 然提供该类型是为了向后兼容。
FLOAT[(p)] BINARY_FLOAT BINARY_DOUBLE INT、INTEGER和SMALLINT
DATE
TIMESTAMP[(n)]
5.1.1 数据类型
对 TIMESTAMP 类型的扩展,存储时区偏 TIMESTAMP[(n)] WITH TIME ZONE 差。时区偏差值为相对于通用协调时间的时 差。 与TIMESTAMP WITH TIME ZONE的区别 在于: TIMESTAMP[(n)] WITH LOCAL TIME 存储数据时直接被转换为数据库时区日 ZONE 期; 读取数据时,用户看到的是会话时区日 期。 存储以年份和月份表示的时间间隔。 n 设 INTERVAL YEAR[(n)] TO MONTH 置年份的数字位数,范围为0~9,默认值为2 。 存储以天、小时、分和秒表示的时间间隔。 m设置天的数字位数,范围为0~9,默认值为 INTERVAL DAY[(m)] TO SECOND[(n)] 2;n设置秒的小数位数,范围为0~9,默认值 为6 。 CLOB 可变长度的字符数据。该类型支持定长和 变长字符集,也可用于数据库字符集。最大 存储128T。 NCLOB 可变长度的Unicode字符数据。该类型支持 定长和变长字符集,也可用于数据库字符集。 最大存储128T。
16
5.1.5 移动表
在创建表时可以为表指定存储空间,如果不指定, Oracle会将该表存储到默认表空间中。根据需要可以 将表从一个表空间中移动到另一个表空间中。语法如 下:
ALTER TABLE table_name MOVE TABLESPACE tablespace_name;
【例5.9】移动person表。首先通过数据字典 user_tables,查看person表当前存储在哪个表空间中, 如下:
参数说明:
schema指示表所属的模式名(缺省:当前用户的帐号); table_name指定要创建的表的名称。表名在当前模式中必须唯一, 长度不能超过30字节,以字母开头,可以包含字母、数字下划线、 美元符号和“#”; column_name指定表中列的名称(字段名),可以定义多个列,多 个列之间用逗号(,)间隔; datatype列的数据类型,Oracle 11g中提供的数据类型如下: DEFAULT指定当前列的默认值; CONSTRAINT为约束命名。定义列级约束时,如果不使用该子句, Oracle系统会自动为约束命名。定义表级约束,必须使用该子句为 约束命名; constraint_def指定约束类型。如UNIQUE、NOT NULL等; TABLESPACE指定存储的表空间;
2.删除列
删除表中的列时可以分为一次删除一列和一次删除多 列。一次删除一列的语法形式如下:
ALTER TABLE table_name DROP COLUMN 【例 5.3】删除 person 表的email列 column_name; ALTER TABLE person DROP COLUMN email ;
4
5.1.1 数据类型
表中的列用于存放数据,这些数据都需要有对 应的数据类型,例如年龄对应整数类型,姓名 对应字符串类型,生日对应日期类型等。 而一种数据类型还可以拥有不同的长度,比如 性别一般是两个字节长度的字符串,姓名一般 是4~8个字节长度的字符串。 Oracle系统提供了功能非常完全的数据类型, 常用的数据类型如表5-1所示。
SQL> SELECT table_name , tablespace_name FROM user_tables 2 WHERE table_name = 'PERSON'; TABLE_NAME ------------------------PERSON TABLESPACE_NAME -----------------------------SYSTEM Nhomakorabea11
5.1.2 创建表
CREATE TABLE person( id NUMBER(4) , name VARCHAR2(8) , sex CHAR(2) , birthday DATE );
【例5.1】创建一个表person,如下:
上述语句创建了一个简单的表person,该表有4个列, 分别为NUMBER(4)类型的id列、VARCHAR2(8)类型 的name列、CHAR(2)类型的sex列和DATE类型的 birthday列。创建该表时没有为该表指定存储表空间, 所以该表将被存放到默认表空间中。
ALTER TABLE person SET UNUSED(age) ;
15
5.1.4 重命名表
ALTER TABLE table_name RENAME TO new_table_name;
重命名表有两种语法形式,一种是使用ALTER TABLE语句,语法如下: 【例5.7】将person表重命名为person01表,如下:
一次删除多列的语法形式如下:
ALTER TABLE table_name DROP (column_name , ...);
13
5.1.3 管理表中的列
3.修改列的名称 修改表中的列的名称的语法如下: ALTER TABLE table_name RENAME COLUMN TO 【例5.4】将表 person的column_name birthday列名称改为age ALTER TABLE person RENAME COLUMN birthday TO age ; new_column_name; 4.修改列的数据类型 修改表中的列的数据类型的语法如下: ALTER TABLE table_name MODIFY 【例5.5 】将表 person 的age列的数据类型改为 NUMBER (4) ALTER column_name TABLE person MODIFY age NUMBER(4) ; new_data_type;
5.1.1 数据类型
数据类型 描述 固定长度的字符串。 n 设置字符串的最大 长度,单位是 BYTE( 字节 ) 或 CHAR( 字符 ) , 默 认 是 BYTE 。 可 以 设 置 的 最 小 长 度 为 1BYTE ,最大为 2000BYTE 。如果实际保存 的字符串的长度大于n,则Oracle会产生错误 信息。 固定长度的 Unicode 字符串。 n 设置字符串 的最大长度,对于AL16UTF16编码,存储的 字节数为2n;对于UTF8编码,存储的字节数 为3n。默认长度为1字符,最大为2000字节。 可变长度的字符串。参数的含义与 CHAR 一样,不过, n 的最大值可以达到4000BYTE。 存储空间的分配根据实际保存的字符串的长 度进行。 可变长度的 Unicode 字符串。 n 设置字符串 的最大长度,对于AL16UTF16编码,存储的 字节数为2n;对于UTF8编码,存储的字节数 为3n。最大为4000字节,必须设置n值。
17
5.1.5 移动表
下面使用ALTER TABLE语句将其移动到users表空间 中,如下:
SQL> ALTER TABLE person MOVE TABLESPACE users; 表已更改。
再次查询数据字典user_tables,观察person表是否已 经移动成功,如下:
SQL> ALTER TABLE person RENAME TO person01; 表已更改。
另一种是直接使用RENAME语句,语法如下:
RENAME table_name TO new_table_name;
【例5.8】将person01表重命名为person表,如下:
SQL> RENAME person01 TO person; 表已重命名。
2
第5章 模 式 对 象
本章要点: 掌握表的创建与管理。 理解并掌握表的完整性约束。 了解索引。 掌握视图的使用。 了解序列。 了解同义词。
3
5.1 表
表是数据库中最常用的模式对象, 用户的数据在数据库中是以表的形式 存储的。 表通常由一个或多个列组成,每个 列表示一个属性,而表中的一行则表 示一条记录。本节主要介绍如何创建 表,以及如何管理表的结构等。
ROWID UROWID[(size)] LONG
RAW(size) LONG RAW
9
5.1.2 创建表
创建表需要使用CREATE TABLE语句,其语法 如下: CREATE TABLE [ schema. ] table_name( column_name data_type [ DEFAULT expression ] [ [ CONSTRAINT constraint_name ] constraint_def ] [ , ... ] )[ TABLESPACE tablespace_name ];