加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

关于表空间offline小知识点

发布时间:2020-12-12 14:04:19 所属栏目:百科 来源:网络整理
导读:1、表空间offline的原因Taking Tablespaces OfflineTaking 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 whi
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操作。大家可以看实验过程了解。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读