130108还原临时表空间
生活随笔
收集整理的這篇文章主要介紹了
130108还原临时表空间
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
臨時表空間由于其特殊性,不能也不需要備份,在臨時表空間出錯時或者還原數據庫到新環境需要新建臨時表空間時,我們使用兩種方法對其進行還原: 方法1)建立新的臨時表空間文件,刪除受損的臨時表空間舊文件; 方法2)替換一個受損的臨時表空間,修改系統默認表空間到新的臨時表空間上; 方法1)建立新的臨時表空間文件,刪除受損的臨時表空間舊文件; SQL> alter tablespace temp begin backup; alter tablespace temp begin backup * ERROR at line 1: ORA-03217: invalid option for alter of TEMPORARY TABLESPACE 由于是臨時表空間,所以不能進行備份,也不需要進行備份 SQL> alter tablespace temp add tempfile 'temp02.dbf' size 10M; Tablespace altered. SQL> select t.name, d.name, d.bytes / 1024 / 1024 from v$tablespace t, v$tempfile d where d.TS# = t.TS#; NAME ------------------------------ NAME ------------------------------------------------------------------------------------------------------------------------ D.BYTES/1024/1024 ----------------- TEMP D:\ORACLE\ORADATA\TEST\TEMP01.DBF 29 TEMP D:\ORACLE\PRODUCT\11.2.0\TEST\DATABASE\TEMP02.DBF 10 NAME ------------------------------ NAME ------------------------------------------------------------------------------------------------------------------------ D.BYTES/1024/1024 ----------------- 由于沒有指定目錄,所以添加臨時表空間文件到默認位置;不是正確位置; SQL> alter database tempfile 'temp01.dbf' offline; alter database tempfile 'temp01.dbf' offline * ERROR at line 1: ORA-01516: nonexistent log file, data file, or temporary file "temp01.dbf" 刪除時需要先offline,并且填寫完整路徑; SQL> alter database tempfile 'D:\ORACLE\ORADATA\TEST\TEMP01.DBF' offline; Database altered. SQL> ALTER DATABASE TEMPFILE 'D:\ORACLE\ORADATA\TEST\TEMP01.DBF' DROP; ALTER DATABASE TEMPFILE 'D:\ORACLE\ORADATA\TEST\TEMP01.DBF' DROP * ERROR at line 1: ORA-25152: TEMPFILE cannot be dropped at this time SQL> ALTER DATABASE TEMPFILE 'D:\ORACLE\ORADATA\TEST\TEMP01.DBF' DROP; ALTER DATABASE TEMPFILE 'D:\ORACLE\ORADATA\TEST\TEMP01.DBF' DROP * ERROR at line 1: ORA-25152: TEMPFILE cannot be dropped at this time 是因為還有用戶在,所以暫時無法刪除; SQL> alter database tempfile 'D:\ORACLE\ORADATA\TEST\TEMP01.DBF' offline; Database altered. SQL> ALTER DATABASE TEMPFILE 'D:\ORACLE\ORADATA\TEST\TEMP01.DBF' DROP; ALTER DATABASE TEMPFILE 'D:\ORACLE\ORADATA\TEST\TEMP01.DBF' DROP * ERROR at line 1: ORA-25152: TEMPFILE cannot be dropped at this time SQL> EXIT 當前用戶由于執行過查詢命令,所以有可能使用到臨時表空間,退出該用戶; Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production PS D:\oracle\diag\rdbms\test\test\trace> PS C:\Users\calvin> SQLPLUS / AS SYSDBA SQL*Plus: Release 11.2.0.1.0 Production on Tue Jan 8 18:00:14 2013 Copyright (c) 1982, 2010, Oracle. ?All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production SQL> ALTER DATABASE TEMPFILE 'D:\ORACLE\ORADATA\TEST\TEMP01.DBF' DROP; Database altered. 重新連接后在此刪除,成功;以上為通過替換一個受損的臨時文件,還原臨時表空間的方法; 方法2)替換一個受損的臨時表空間,修改系統默認表空間到新的臨時表空間上; 新建臨時表空間 temp02; SQL> CREATE temporary tablespace TEMP02 TEMPFILE 'D:\ORACLE\ORADATA\TEST\TEMP02_A.DBF' SIZE 10M; Tablespace created. 將數據庫默認的臨時表空間修改為新建的臨時表空間; SQL> alter database default temporary tablespace TEMP02; Database altered. 刪除舊的臨時表空間,一并將系統磁盤上的內容及數據文件刪除; SQL> drop tablespace temp including contents and datafiles; Tablespace dropped. SQL>
轉載于:https://blog.51cto.com/1310976/1111921
總結
以上是生活随笔為你收集整理的130108还原临时表空间的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: windows 2008 R2下(AD
- 下一篇: 关注CIO:IT运维如何实现“向管理要效