Ask MySelf - OCA

Ask MySelf – OCA..... 1

-- Create by afoxwwk (Paul wu)

-- E-mail:afoxwwk@itpub.net

1. 关于Ask MySelf - OCA 2

2. 几个基本的环境变量的作用是? 2

3. oraInst.loc、orainstRoot.sh和root.sh 的作用是? 2

4. 区分设置文件存放路径的参数 3

5. Oracle内存的作用和组成? 3

6. 后台进程何时进行工作? 4

7. ORACLE启动过程? 5

8. 什么是SCN? 5

9. 控制文件包括哪些内容? 5

10. Checkpoint的作用是? 6

11. 数据库在何时会发生Checkpoint? 6

12. 怎样区分左连接、右连接和全连接?. 6

13. Char与Varchar、vharchar2有什么区别? 7

14. 使用Substitution Variables时&与&&有什么区别?. 7

15. 表命名规则 7

16. 两个实用的数据字典表 8

17. 在专用服务器和共享服务器中内存的变化 8

18. 表空间有哪几种管理方式?. 8

[@more@]

19. 表空间的相关SQL 9

20. SYSDBA与SYSOPER 有什么区别? 10

21. 如何使用审计?... 10

22. 怎样预算UNDO表空间的大小? 12

23. 没有提交的数据在断开连接后会不会丢失? 12

24. 撤消表空间在数据库恢复中有什么作用? 12

25. 怎样利用回闪和Recycle bin恢复删除的数据? 12

26. Alert log 包含哪些信息? 14

27. Nologging跟REDO有什么关系? 14

28. TEMP表空间有什么作用? 14

29. Redo和Undo之间有什么关系? 14

30. 怎样建立有效率的索引? 14

31. 表之间有哪几种连接类型 ?. 15

32. SQL_TRACE和TKPROF的作用和使用方法? 15

33. 关于LRU链的管理 20

34. 什么是等待事件?. 20

35. 关于Latch Free 20

36. 关于热点块 20

37. Buffer Hit Ratio的计算方法 30

1. 关于Ask MySelf - OCA

学习OCA过程中突然有个想法,多问自己为什么,把自己提问的问题记录下来,然后一一解答,觉得这是个不错的方法,可以促进自己的学习,还可以积累知识。整理的这些问题很多不会出现在OCA考试中,但我想很多会对自己的对ORACLE技术的掌握和工作有所帮助。

2. 几个基本的环境变量的作用是?

ORACLE_BASE: Specifies the base of the Oracle directory structure for OFA.

ORACLE_HOME: Specifies the directory containing the Oracle software.

ORACLE_SID: The initial instance name (ORCL by default). It is a string of numbers and letters that must begin with a letter. Oracle Corporation suggests that a maximum of eight characters be used for system identifiers.

NLS_LANG: Specifies the initial National Language Support (NLS) settings for a session in the form of language_territory.character set. Format: language_territory.character

3. oraInst.locorainstRoot.shroot.sh 的作用是?

The orainstRoot.sh file creates the inventory pointer file while installing the Oracle 10g database on a Linux platform

The file oralnst.loc which is used by Oracle Universal Installer at startup to find the inventory location

4. 区分设置文件存放路径的参数

audit_file_dest …ADUMP 用来写入审计跟踪信息的位置。

background_dump_dest …BDUMP存放alert日志和任何跟踪文件的地方。

core_dump_dest …CDUMP发生崩溃的操作系统进程将要用来写入核心转储文件的地方。

user_dump_dest …UDUMP用户进程所生成的任何跟踪文件将要写到的地方。

db_create_file_dest OMF(Oracle Managed Files)

db_recovery_file_dest …product10.2.0/flash_recovery_area

standby_archive_dest %ORACLE_HOME%RDBMS

5. Oracle内存的作用和组成?

Oracle uses memory to store information such as the following:

Program code

Information about a connected session, even if it is not currently active

Information needed during program execution (for example, the current state of a

query from which rows are being fetched)

Information that is shared and communicated among Oracle processes (for

example, locking information)

Cached data that is also permanently stored on peripheral memory (for example,

data blocks and redo log entries)

Oracle Memory Structures

The basic memory structures associated with an Oracle instance include:

System Global Area (SGA): Shared by all server and background processes

Program Global Area (PGA): Private to each server and background process; there is one PGA for each process

The SGA is a memory area that contains data and control information for the instance.

The SGA includes the following data structures:

Block buffer cache(块缓冲区缓存): Caches blocks of data retrieved from the database,

include:default pool,keep pool,recycle pool

Redo log buffer(重做缓存区): Caches redo information (used for instance recovery) until it can be written to the physical redo log files stored on the disk

9i&10g编程艺术的书中提到,重做缓冲区的默认大小由LOG_BUFFER参数控制,值为512KB和(128*CPU个数)KB中的较大者。但实际上10G中默认的LOG_BUFFER超过2M,有待验证。

Shared pool: Caches various constructs that can be shared among users

Large pool: Is an optional area that provides large memory allocations for certain large processes, such as Oracle backup and recovery operations, and I/O server processes

Java pool: Is used for all session-specific Java code and data within the Java Virtual Machine (JVM)

Streams pool: Is used by Oracle Streams

When you start the instance by using Enterprise Manager or SQL*Plus, the amount of memory allocated for the SGA is displayed.

Fixed sga(固定SGA)

6. 后台进程何时进行工作

DBWn

把修改后的数据库块从SGADatabase Buffer Cache中写到磁盘上的数据文件,即把脏数据写到数据文件上,

Database Writer进程何时进行工作:

¨ 用户的Sever Process在把一个缓冲器读取到Buffer Cache中时搜索一个自由缓冲器的花费的时间太长;

¨ Database Buffer中被修改和提交但未被写入的缓冲器数量太大,

¨ 当发生一个数据库Checkpoint事件时

¨ 实例使用了关闭异常之外的任何一种方法被关闭。

¨ 一个表空间被置于备份模式。

¨ 一个表空间被变成脱机状态而使它变得不可使用,或被改成READ ONLY模式。

¨ 一个段被删除.

LGWR

把事务恢复信息从SGARedo Log Buffer中写到磁盘上的联机Redo Log文件。

Log Writer进程何时进行工作:

¨ 每隔三秒钟

¨ 用户提交一个事务

¨ Redo Log Buffer 为三分之一满。

¨ Redo Log Buffer 含有1MB的重做信息量。

¨ 在一个数据库检查点一出现时

¨ DBWn进程开始工作之前。

PMON (Pocess Mnitor)

负责在出现异常中止的连接之后完成清理,PMON还负责监视其它后台进程的运行情况,另外负责向监听器进行注册实例。

SMON (System Monitor)

PMON针对单个进程相比,SMON以系统为出发点,SMON主要工作包括 :

¨ 清理临时表空间

¨ 合并空闲的空间(用于字典管理的表空间)

¨ 针对原来不可用的文件恢复活动的事务

¨ 执行RAC中失败节点的实例恢复

¨ 清理OBJ$

¨ 收缩回滚段

¨ “离线”回滚段

CKPT (Checkpoint Process)

负责更新Checkpoint Event后面的数据文件的首部,CKPT并不建立检查点,真正建立检查点的是DBWn进程.

7. ORACLE启动过程?

NOMOUNT,

首先寻找参数文件,然后根椐参数文件中的设置创建实例,分配内存,启动后台进程。Oracle寻找参数文件的优先顺序为:Spfile.ora --&gtSpfile.ora--&gtinit.ora

MOUNT

读取和更新控制文件,另外还需读取口令文件,该文件位于$ORACLE_HOME/dbs目录下,缺省名称为

OPEN

根据控制文件的数据文件、日志文件的位置、检查点等信息找到这些文件和进行检查点及完整性检查。

检查数据文件头中的检查点计数是否和控制文件中的检查点计数一致。

8. 什么是SCN

System Change(commit) Number(系统改变号) Oracle内部的时钟机制,Oracle通过SCN来维护数据库的一致性,并通过SCN实施Oracle的恢复机制。

作用:

1)数据文件头中包含了该数据文件的Checkpoint SCN,表示该数据文件最近一次执行检查点操作的SCN

2)每个日志文件中包含了Low SCNNext Scn,Current的日志文件的Next SCN被置为无穷大。在进行恢复可以根据这两个SCN确定需要的恢复信息位于哪一个日志文件中。

9i版本以上查看当前SCNSelect dbms_flashback.get_system_change_number From dual

9. 控制文件包括哪些内容?

如下:

¨ The contents of the control file include the following:

¨ The database name to which the control file belongs. A control file can belong to only one

¨ database.

¨ The database creation time stamp.

¨ The name, location, and online/offline status information of the datafiles.

¨ The name and location of the redo log files.

¨ Redo log archive information.

¨ Tablespace names.

¨ The current log sequence number, which is a unique identifier that is incremented and recorded when an online redo log file is switched.

¨ The most recent checkpoint information.

¨ The beginning and ending of undo segments.

¨ Recovery Manager’s backup information.

The control file size is determined by the MAX clauses you provide when you create the database:

¨ MAXLOGFILES

¨ MAXLOGMEMBERS

¨ MAXLOGHISTORY

¨ MAXDATAFILES

¨ MAXINSTANCES

10. Checkpoint的作用是?

一个检查点就是一个从缓冲器高速缓存中将己修改的数据写到磁盘上并更新控制文件与数据文件的事件,它存在的根本意义在于减少崩溃恢复(Crash Recovery)时间。当检查点发生时,Oracle会通知DBWR进程把修改过的数据,也就是些Checkpoint SCN之前的脏数据从Buffer Cache写入磁盘,当完成写入后,CKPT进程更新控制文件和数据文件头。

11. 数据库在何时会发生Checkpoint

¨ 重做日志文件被填满和一个日志切换发生时;

¨ 实例通过使用NormalTransactionalImmediate命令被关闭时;

¨ 表空间状态被子改变到只读或被置入Backup方式时;

¨ 某些参数所指定的其他值被达到时;如fast_start_mttr_target

强制实施一个检查点:

Alter system checkpoint;

强制实施一个日志文件切换:

Alter system switch logfile;

12. 怎样区分左连接、右连接和全连接?

Create table test_join_1 (id number,income number);

Create table test_join_2 (id number,name varchar2(11);

右连接:
Select * From test_join_1 Right Join test_join_2 On test_join_2.Id = test_join_1.Id;

等价于:

Select * From test_join_1 ,test_join_2 Where test_join_1.Id(+) = test_join_2.Id;

左连接:
Select * From test_join_1 Left Join test_join_2 On test_join_1.Id = test_join_2.Id

等价于:

Select * From test_join_1 ,test_join_2 Where test_join_1.Id = test_join_2.Id(+);

全连接:
Select * From test_join_1 full Join test_join_2 On test_join_2.Id = test_join_1.Id;

13. CharVarcharvharchar2有什么区别?

Char 始终固定宽类型的列数据,按需要在右边填充空格。
Varchar 只存储得到实际使用的数据量,VARCHAR VARCHAR210G中是同义的,但推荐使用VARCHAR2.

Long 为向后兼容而保留的数据类型。每个表只能使用一个LONG类型列,有一个LONG的表不能被分区,LONG数据类型不能用于子查询,而且只有少量函数能处理LONG数据。

14. 使用Substitution Variables&&&有什么区别?

&&&的区别

Using Substitution Variables

Select * from test where id = &id;

sqlplus 执行上面的语句,将每次提示输入变量id的值;

Select * from test where id = &&id;

sqlplus 执行上面的语句,在同一个session中只会提示一次输入变量id的值;

15. 表命名规则

¨ 长度必须在130个字节之前;

¨ 必须以一个字母开头;

¨ 能够包含字母、数值、下划线符(_)、英镑符号(#)和美元符号(#)和美元符号($)(ORACLE不鼓励在名称中使用英镑和美元符号

¨ 不能是一个像NUMBERINDEX这样的保留字

表和视图共用一个名称空间.

16. 两个实用的数据字典表

查看指定表的作用
Select * From Dictionary
Where table_name =
''
查看指定表字段的作用
Select * From dict_columns
Where table_name =
'

17. 在专用服务器和共享服务器中内存的变化

如果使用共享服务器,UGASGA中分配,如果是使用专用服务器,则从PGA中分配UGA

ORACLESGA增加两种新型的结构:请求队列和响应队列。

18. 表空间有哪几种管理方式?

盘区管理方式:

Dictionary-managed tablespaces(目录管理表空间)

数据库跟琮数据目录中的自由和己用盘区,因而利用递归SQL来修改FET$UET$表。

Locally managed tablespaces(本地管理表空间)

使用每个数据文件中存储的一个位图来管理体制区段,现在要得到一个区段,系统所做的只是在位图中将某一位设置为1,要释放空间,系统再把这一位设置为0,本地管理表空间是默认设置。(9i以上版本,如果system表空间为本地管理方式,则其它所有表空间都为本地管理方式,而且该数据库将不能建立目录管理方式的表空间)

Example:

Create tablespace testspace datafile ‘’size 10M

Extent management local (uniform size 1M)/autoallocate;

Uniform:指定盘区大小。

Autoallocate:自动分配大小。

DBMS_SPACE_ADMIN可相互转换这两种管理方式(SYSTEM表空间不能将目录管理方式转为本地管理方式).

段空间管理方式

手工段空间管理方式(Manual)

This specifies that you want to use free lists for managing free space within segments. Free lists are lists of data blocks that have space available for inserting rows. This form of managing space within segments is called manual segment space management because of the need to specify and tune the PCTUSED, FREELISTS, and FREELIST GROUPS storage parameters for schema objects created in the tablespace. This is supported for backward compatibility; it is recommended that you use ASSM.

自动段空间管理方式(Auto)

The Oracle database uses bitmaps to manage the free space within segments. The bitmap describes the status of each data block within a segment with respect to the amount of space in the block that is available for inserting of rows. As more or less space becomes available in a data block, its new state is reflected in the bitmap. With bitmaps, the Oracle database manages free space more automatically and, thus, this form of space management is called Automatic Segment Space Management (ASSM).

如数据库没有指定的默认用户表空间和临时表空间,那这个用户将使用system作为自己的默认表空间和临时表空间.

19. 表空间的相关SQL

-- Create a tablespace:

CREATE TABLESPACE hist2004apr DATAFILE '/ORADATA/PROD/HIST2

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/171059/viewspace-997278/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/171059/viewspace-997278/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值