关于表空间offline小知识点

前端之家收集整理的这篇文章主要介绍了关于表空间offline小知识点前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
1、表空间offline的原因
Taking Tablespaces Offline
Taking a tablespace offline makes it unavailable for normal access.

You may want to take a tablespace offline for any of the following reasons:

To make a portion of the database unavailable while allowing normal access to the remainder of the database

To perform an offline tablespace backup (even though a tablespace can be backed up while online and in use)

To make an application and its group of tables temporarily unavailable while updating or maintaining the application

To rename or relocate tablespace data files  ##上次文档就是因为要重命名数据文件offline了表空间
实验1
sql> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            +DATADG/arch
Oldest online log sequence     266
Next log sequence to archive   268
Current log sequence           268
sql> 

sql> alter tablespace users offline ;  ##默认使用normal参数
Tablespace altered.

sql> alter system switch logfile;
System altered.

sql> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
sql> 
sql> startup
ORACLE instance started.

Total System Global Area 1653518336 bytes
Fixed Size                  2253784 bytes
Variable Size            1006636072 bytes
Database Buffers          637534208 bytes
Redo Buffers                7094272 bytes
Database mounted.
Database opened.
sql> 
sql> alter tablespace users online;
Tablespace altered.

sql> select tablespace_name,status from dba_tablespaces;
TABLESPACE_NAME                STATUS
------------------------------ ---------
SYSTEM                         ONLINE
SYSAUX                         ONLINE
UNDOTBS1                       ONLINE
TEMP                           ONLINE
USERS                          ONLINE
UNDOTBS2                       ONLINE
6 rows selected.

sql>
实验2
sql> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            +DATADG/arch
Oldest online log sequence     267
Next log sequence to archive   269
Current log sequence           269
sql> alter tablespace users offline immediate;  ##参数immediate

Tablespace altered.

sql> alter system switch logfile;

System altered.

sql> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
sql> startup
ORACLE instance started.

Total System Global Area 1653518336 bytes
Fixed Size                  2253784 bytes
Variable Size            1006636072 bytes
Database Buffers          637534208 bytes
Redo Buffers                7094272 bytes
Database mounted.
Database opened.
sql> alter tablespace users online;
alter tablespace users online
*
ERROR at line 1:
ORA-01113: file 4 needs media recovery
ORA-01110: data file 4: '+DATADG/orcl/datafile/users.259.954803993'

sql> recover tablespace users;
Media recovery complete.
sql> alter tablespace users online;

Tablespace altered.

sql> select tablespace_name,status from dba_tablespaces;

TABLESPACE_NAME                STATUS
------------------------------ ---------
SYSTEM                         ONLINE
SYSAUX                         ONLINE
UNDOTBS1                       ONLINE
TEMP                           ONLINE
USERS                          ONLINE
UNDOTBS2                       ONLINE

6 rows selected.

sql>

小结:默认offline表空间执行一致性检查点,使用normal参数来offline表空间。如果使用immediate参数offline表空间需要进行recover操作。大家可以看实验过程了解。

原文链接:https://www.f2er.com/oracle/206401.html

猜你在找的Oracle相关文章