标签:hat sso res dba size rar -o extent when
Managing Database Storage Structures 管理DB存储架构you should be able to:
1、Describe the storage of table row data in blocks
2、Create and manage tablespaces
3、Obtain tablespace information
desc dba_segments;
desc dba_extents;
例 循环插入:
declare
begin
for i in 1..100 loop
insert into hr.emp select * from hr.employess
end loop
end
/
alter system checkpoint; 提交内存数据写入磁盘;
创建表空间
redo :执行的操作语句
undo :原始数据,回滚用
conn hr/hr;
select * from session_privs;
show parameter undo;
注:离线offline mode 有三种: normal 、temporary、immediate
oracle表空间offline的三种方式区别
temporary:
A tablespace can be taken offline temporarily, even if there are
error conditions for one or more files of the tablespace. When
you specify OFFLINE TEMPORARY, the database takes offline the
datafiles that are not already offline, checkpointing them as it
does so.
If no files are offline, but you use the temporary clause, media
recovery is not required to bring the tablespace back online.
However, if one or more files of the tablespace are offline
because of write errors, and you take the tablespace offline
temporarily, the tablespace requires recovery before you can
bring it back online.
注意事项
如果必须离线表空间,推荐使用offline normal 方式离线该表空间,因为该表空间online时不需要执行介质恢复。
三 实验
1 测试offline temporary
查询系统当前表空间以及相应的数据文件
SQL> select a.name as tablespace,b.file#,b.status,b.name as datafile from v$tablespace a,v$datafile b where a.ts#=b.ts#;
TABLESPACE FILE# STATUS DATAFILE
SYSTEM 1 SYSTEM /oracle/CRM2/CRM/system01.dbf
SYSAUX 3 ONLINE /oracle/CRM2/CRM/sysaux01.dbf
USERS 4 ONLINE /oracle/CRM2/CRM/users01.dbf
UNDOTBS2 6 ONLINE /oracle/CRM2/CRM/undotbs2.dbf
ZX 5 ONLINE /oracle/CRM2/CRM/zx1.dbf
ZX 2 ONLINE /oracle/CRM2/CRM/zx2.dbf
SQL> alter database datafile 2 offline;
Database altered.
不能用offline normal正常offline 因为表空间zx数据文件2已经offline状态
SQL> alter tablespace zx offline;
alter tablespace zx offline
*
ERROR at line 1:
ORA-01191: file 2 is already offline - cannot do a normal offline
ORA-01110: data file 2: ‘/oracle/CRM2/CRM/zx2.dbf‘
用offline temporary 离线
SQL> alter tablespace zx offline temporary;
Tablespace altered.
SQL> alter tablespace zx online;
alter tablespace zx online
*
ERROR at line 1:
ORA-01113: file 2 needs media recovery
ORA-01110: data file 2: ‘/oracle/CRM2/CRM/zx2.dbf‘
SQL> recover datafile 2;
Media recovery complete.
使zx表空间online
SQL> alter tablespace zx online;
Tablespace altered.
2 测试offline immediate
查询当前表空间及其数据文件。
SQL> select a.name as tablespace,b.file#,b.status,b.name as datafile from v$tablespace a,v$datafile b where a.ts#=b.ts#;
TABLESPACE FILE# STATUS DATAFILE
SYSTEM 1 SYSTEM /oracle/CRM2/CRM/system01.dbf
SYSAUX 3 ONLINE /oracle/CRM2/CRM/sysaux01.dbf
USERS 4 ONLINE /oracle/CRM2/CRM/users01.dbf
UNDOTBS2 6 ONLINE /oracle/CRM2/CRM/undotbs2.dbf
ZX 5 ONLINE /oracle/CRM2/CRM/zx1.dbf
ZX 2 ONLINE /oracle/CRM2/CRM/zx2.dbf
SQL> alter tablespace zx offline immediate;
Tablespace altered.
SQL> alter tablespace zx online;
alter tablespace zx online
*
ERROR at line 1:
ORA-01113: file 2 needs media recovery
ORA-01110: data file 2: ‘/oracle/CRM2/CRM/zx2.dbf‘
SQL> recover datafile 2;
Media recovery complete.
SQL> alter tablespace zx online;
alter tablespace zx online
*
ERROR at line 1:
ORA-01113: file 5 needs media recovery
ORA-01110: data file 5: ‘/oracle/CRM2/CRM/zx1.dbf‘
SQL> recover datafile 5;
Media recovery complete.
SQL> alter tablespace zx online;
Tablespace altered.
例:
drop tablespace test;
create table tt1 tablespace test as select * from hr.regions;
删表空间: drop tablespace test1 include contents and datafiles;
select tablespace_name, status from dba_tablespaces;
OMF->指定文件路径
SQL>select member from v$logfile;
SQL>show parameter db_create;
标签:hat sso res dba size rar -o extent when
原文地址:http://blog.51cto.com/3938853/2162729