Ask MySelf - OCA -2
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
[@more@]-- Create a tablespace:
CREATE TABLESPACE hist2004apr DATAFILE '/ORADATA/PROD/HIST2004APR.DBF' SIZE 25G
EXTENT MANAGEMENT LOCAL AUTOALLOCATE(or uniform size X/dictionary)
SEGMENT SPACE MANAGEMENT AUTO(or manual);
CREATE TEMPORARY TABLESPACE temp
TEMPFILE 'C:ORACLEORADATAORA10TEMP01.DBF' SIZE 2G
CREATE UNDO TABLESPACE undo
DATAFILE 'c:test2.dbf' SIZE 5M ;
-- DROP OR MODIFY tablespace:
DROP TABLESPACE hr_data INCLUDING CONTENTS AND DATAFILES CASCADE CONSTRAINTS(包括关联对象);
ALTER TABLESPACE fin RENAME TO payables;
ALTER TABLESPACE receivables ADD Datafile '/u02/oradata/ORA10/receivables01.dbf' SIZE 2G;
ALTER TABLESPACE sales2003 READ ONLY(or Write);
Alter TABLESPACE payables Online;
Alter TABLESPACE payables offline [normal/temporary/immediate];
ALTER TABLESPACE system BEGIN(END) BACKUP;
ALTER DATABASE DATAFILE 'c:test2.dbf' RESIZE 5M;
Alter DATABASE Datafile 'c:test3.dbf' AUTOEXTEND ON NEXT 1M MAXSIZE 10M ;
ALTER DATABASE Datafile 'C:TEST2.DBF' Offline/online;
-- Rename a datafile:
Alter tablespace receivables offline;
Cp…
ALTER TABLESPACE receivables RENAME DATAFILE 'H:ORACLEORADATAORA10RECEIVABLES02.DBF' TO 'G:ORACLEORADATAORA10RECEIVABLES02.DBF' ;
或 ALTER DATABASE Rename file 'H:ORACLEORADATAORA10RECEIVABLES02.DBF'
TO 'G:ORACLEORADATAORA10RECEIVABLES02.DBF';
Alter tablespace receivables online;
查看指定对象的DDL?
SELECT DBMS_METADATA.GET_DDL('TABLESPACE','TEST')FROM dual;
-- 8i不支持
20.
SYSDBA
与
SYSOPER
有什么区别?
SYSDBA and SYSOPER: These privileges allow you to shut down, start up, and perform recovery and other administrative tasks in the database. SYSOPER allows a user to perform basic operational tasks, but without the ability to look at user data. It includes the following system privileges:
l STARTUP and SHUTDOWN
l CREATE SPFILE
l ALTER DATABASE OPEN/MOUNT/BACKUP
l ALTER DATABASE ARCHIVELOG
l ALTER DATABASE RECOVER (Complete recovery only. Any form of incomplete recovery, such as UNTIL TIME|CHANGE|CANCEL|CONTROLFILE requires connecting as SYSDBA.)
l RESTRICTED SESSION
The SYSDBA system privilege additionally authorizes incomplete recovery and the deletion of a database. Effectively, the SYSDBA system privilege allows a user to connect as the SYS user.
--设置参数
Alter System Set audit_trail=DB scop=Spfile;--启用语句审计
Audit session;
Audit Table By fox Whenever Not Successful;
Audit Insert Table By fox By Access;
...--禁用语句审计
Noaudit Session;
...--相关视图
Sys.Aud$
dba_audit_tral
Dba_Stmt_Audit_Opts
*********************--管理特权审计
Audit Create Any Table;
Audit Delete Any Table By fox By Access;
...--禁用特权审计
Noaudit Alter pofile;--查看己启用的特权审计
Select * From dba_priv_audit_opts
*********************--管理对象审计--模式对象审计不能被限定于指定用户
Audit Select On tab_test;--禁用对象审计
Noaudit Select On tab_test Whenever Not Successful;;--查看己启用的对象审计
Select * From dba_obj_audit_opts
*********--管理精细审计--Fine-graied auditing,FGA.允许读者基于数据的内容监视和记录数据访问--创建FGA策略(例)
dbms_fga.add_policy(object_schema=>'HR'
,object_name=>'EMPLOYEES'
,policy_name=>'COMPENSATION_AUD'
,audit_column=>'SALARY,COMMISSION_PCT'
,Enable=>False
,statement_types=>'select');--启用FGA策略
dbms_fga.enable_policy(object_schema=>'HR'
,object_name=>'EMPLOYEES'
,policy_name=>'COMPENSATION_AUD');--关闭FGA策略
dbms_fga.disable_policy(object_schema=>'HR'
,object_name=>'EMPLOYEES'
,policy_name=>'COMPENSATION_AUD');--删除FGA策略
dbms_fga.drop_policy(object_schema=>'HR'
,object_name=>'EMPLOYEES'
,policy_name=>'COMPENSATION_AUD');--查看定义的FGA策略
Select * From dba_audit_policies;
Select * From dba_fga_audit_trail;
22.
怎样预算
UNDO
表空间的大小?
利用公式
:
Undo_tablespace_size = Undo retention(UR) * Undo per second(UPS) *Db_block_size;
UPS is the maximum undo blocks used per second from the undoblks column in V$UNDOSTAT.
Select max(undoblks) UPS from V$UNDOSTAT.
附:
Undo data的用途:
Oracle在数据被修改之前把己经存在的数据旧值保存为撤消数据。
1) 用户对一个事务的回退;
2) DML操作和查询的读一致性;
3) 数据库恢复操作;
4) 回闪功能。
在一个连接正常退出或数据库正常关闭时会将所有没有COMMIT的数据提交,但如果连接异常关闭或数据库异常关闭时会ROLLBACK所有未提交的数据。
在SG中有:“The undo tablespace is a key component for database recovery in the case of an instance failure.After the online redo log files bring both committed and uncommitted transactions forward to
the point of the instance crash, the undo data in the tablespace is used to roll back the uncommitted
transactions.”
25.
怎样利用回闪和
Recycle bin
恢复删除的数据?
1,
确保数据库有一个撤消表空间,并有足够的空间保存用户在一个指定的时间段内所做的修改;
2,
使用
UNDO_RETETION
参数,指定撤消数据保留的时间;
回闪查询
:
select count(*) from test as of timestamp(sysdate-1/24);
关于
Flashback drop
和
recycle bin(
回收站
)(10G
新功能
)
Recycle bin
是每个表空间内的一个逻辑结构,它用来保存己删除的表和那些表所关联的对象;己删除表所关联着的空间不是立即可供使用的,但出现在数据视图
DBA_FREE_SPACE
中。当表空间中出现空间压力时,回收站中的对象按照先进先出(
FIFO
)方式被删除。
查看
Recycle bin
中的对象
Select * from user_recycle;
Select * from dba_recycle;
Show recycle;
注:
1)
只有非
system
的本地管理式表空间能够含有一个回收站
。但是,如果己删除对象驻留在一个本地管理式表空间,那么驻留在目录管理式表空间中的依赖对象得到保护。
2)
在删除一个表时,除了位图连接索引、参考完整性约束(即外部键约束)和物化视图日志之外,这个表的依赖对象均被保存在回收站中。
3)
索引仅当这个表先被删除时才得到保护;明确地删除一个索引不会将该索引放置到回收站中。
flashback table test to before drop;
要想回闪一个表,
DBA
必须启用该表的行转移:
alter table test enable row movement;
alter table test disenable row movement;
flashback table test to timestamp(sysdate-1/240);
怎样从重做日志文件的丢失中恢复?
1
)证实缺少哪能个重做日志文件组成员。
2
)所这个重做日志文件组的内容存档;
alter system archive log group groupnum;
3)
使用
alter database clear logfile group groupnum;
26. Alert log
包含哪些信息
?
Ø 启动和关闭信息,其中包括每次启动和关闭数据库的记录。
Ø 某些类型的管理性动作,比如ALTER SYSTEM或ALTER DATABASE命令。
Ø 某些类型的数据错误,比如内部ORACLE错误(比如ORA-600错误)或空间错误。
Ø 初始化参数的新值。
Ø
每当发生一个日志切换时。
27.
Nologging
跟
REDO
有什么关系
?
28.
TEMP
表空间有什么作用
?
1.You can manage space for sort operations more efficiently by designating one or more temporary tablespaces exclusively for sorts.
2.One or more temporary tablespaces can be used only for sort segments.
3.Temporary tablespaces provide performance improvements when you have multiple sorts that are too large to fit into memory.
Each user has a temporary tablespace. When a user runs a SQL statement that requires the creation of temporary segments (such as the creation of an index), the user's temporary tablespace is used. By directing all users' temporary segments to a separate tablespace, the temporary tablespace can reduce I/O contention among temporary segments and other types of segments.
摘自:
Oracle® Database Concepts
10g Release 2 (10.2)
29. Redo和Undo之间有什么关系?
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/171059/viewspace-997284/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/171059/viewspace-997284/