oracle移動數據/修改數據文件路徑

oracle移動數據/修改數據文件路徑 html

SQL> col TABLESPACE_NAME  format a20
SQL> col TOTAL_BYTES  format a20
SQL> select * from (Select a.tablespace_name, to_char(a.bytes/1024/1024,'99,999.999') total_bytes,  to_char(b.bytes/1024/1024,'99,999.999') free_bytes,  to_char(a.bytes/1024/1024 - b.bytes/1024/1024,'99,999.999') use_bytes,  to_char((1 - b.bytes/a.bytes)*100,'99.99') || '%' use from (select tablespace_name,  sum(bytes) bytes from dba_data_files  group by tablespace_name) a,  (select tablespace_name,  sum(bytes) bytes  from dba_free_space  group by tablespace_name) b where a.tablespace_name = b.tablespace_name  union all  select c.tablespace_name,  to_char(c.bytes/1024/1024,'99,999.999') total_bytes,  to_char( (c.bytes-d.bytes_used)/1024/1024,'99,999.999') free_bytes,  to_char(d.bytes_used/1024/1024,'99,999.999') use_bytes, to_char(d.bytes_used*100/c.bytes,'99.99') || '%' use  from (select tablespace_name,sum(bytes) bytes  from dba_temp_files group by tablespace_name) c, (select tablespace_name,sum(bytes_cached) bytes_used  from v$temp_extent_pool group by tablespace_name) d  where c.tablespace_name = d.tablespace_name);

TABLESPACE_NAME      TOTAL_BYTES          FREE_BYTES                        USE_BYTES                         USE
-------------------- -------------------- --------------------------------- --------------------------------- ---------------------
SYSAUX                   760.000               92.000                           668.000                        87.89%
USERS                      5.000                 .813                             4.188                        83.75%
SYSTEM                   828.000               71.188                           756.813                        91.40%
EXAMPLE                  100.000               21.250                            78.750                        78.75%
UNDOTBS2                 150.000               46.188                           103.813                        69.21%
MYMOTIF_TS               100.000               95.500                             4.500                         4.50%
TEMP                       8.992                 .992                             8.000                        88.97%

已選擇7行。


SQL> col Schema for a25;
SQL> col Item for a25;
SQL> col move_procedure for a40;
SQL> SELECT occupant_name "Item", space_usage_kbytes / 1024 "Space Used (MB)", schema_name "Schema", move_procedure  FROM v$sysaux_occupants ORDER BY 1 ;

Item                      Space Used (MB) Schema                    MOVE_PROCEDURE
------------------------- --------------- ------------------------- ----------------------------------------
AO                                     42 SYS                       DBMS_AW.MOVE_AWMETA
AUDIT_TABLES                            0 SYS                       DBMS_AUDIT_MGMT.move_dbaudit_tables
AUTO_TASK                           .3125 SYS
EM                                99.6875 SYSMAN                    emd_maintenance.move_em_tblspc
EM_MONITORING_USER                 1.3125 DBSNMP
EXPRESSION_FILTER                   3.625 EXFSYS
JOB_SCHEDULER                      5.0625 SYS
LOGMNR                              7.875 SYSTEM                    SYS.DBMS_LOGMNR_D.SET_TABLESPACE
LOGSTDBY                            1.375 SYSTEM                    SYS.DBMS_LOGSTDBY.SET_TABLESPACE
ORDIM                               .4375 ORDSYS                    ordsys.ord_admin.move_ordim_tblspc
ORDIM/ORDDATA                       12.75 ORDDATA                   ordsys.ord_admin.move_ordim_tblspc

Item                      Space Used (MB) Schema                    MOVE_PROCEDURE
------------------------- --------------- ------------------------- ----------------------------------------
ORDIM/ORDPLUGINS                        0 ORDPLUGINS                ordsys.ord_admin.move_ordim_tblspc
ORDIM/SI_INFORMTN_SCHEMA                0 SI_INFORMTN_SCHEMA        ordsys.ord_admin.move_ordim_tblspc
PL/SCOPE                           1.5625 SYS
SDO                               53.0625 MDSYS                     MDSYS.MOVE_SDO
SM/ADVISOR                        30.0625 SYS
SM/AWR                                 94 SYS
SM/OPTSTAT                             58 SYS
SM/OTHER                              7.5 SYS
SMON_SCN_TIME                        3.25 SYS
SQL_MANAGEMENT_BASE                1.6875 SYS
STATSPACK                               0 PERFSTAT

Item                      Space Used (MB) Schema                    MOVE_PROCEDURE
------------------------- --------------- ------------------------- ----------------------------------------
STREAMS                                 1 SYS
TEXT                                  3.5 CTXSYS                    DRI_MOVE_CTXSYS
TSM                                     0 TSMSYS
ULTRASEARCH                             0 WKSYS                     MOVE_WK
ULTRASEARCH_DEMO_USER                   0 WK_TEST                   MOVE_WK
WM                                 3.0625 WMSYS                     DBMS_WM.move_proc
XDB                              128.0625 XDB                       XDB.DBMS_XDB.MOVEXDB_TABLESPACE
XSAMD                              7.3125 OLAPSYS                   DBMS_AMD.Move_OLAP_Catalog
XSOQHIST                               42 SYS                       DBMS_XSOQ.OlapiMoveProc

已選擇31行。

 

SQL> col PARTITION_NAME  format a30
SQL> col SEGMENT_NAME  format a30
SQL> col SEGMENT_TYPE   format a15

SQL> select * from (select segment_name,PARTITION_NAME,segment_type,bytes/1024/1024 from dba_segments where tablespace_name='SYSTEM' order by 4 desc) where rownum<=20;

SEGMENT_NAME                   PARTITION_NAME                 SEGMENT_TYPE    BYTES/1024/1024
------------------------------ ------------------------------ --------------- ---------------
IDL_UB1$                                                      TABLE                       248
SOURCE$                                                       TABLE                        64
IDL_UB2$                                                      TABLE                        30
C_TOID_VERSION#                                               CLUSTER                      23
C_OBJ#_INTCOL#                                                CLUSTER                      15
I_SOURCE1                                                     INDEX                        12
C_OBJ#                                                        CLUSTER                      11
JAVA$MC$                                                      TABLE                        11
ARGUMENT$                                                     TABLE                        11
IDL_CHAR$                                                     TABLE                        10
OBJ$                                                          TABLE                         8

SEGMENT_NAME                   PARTITION_NAME                 SEGMENT_TYPE    BYTES/1024/1024
------------------------------ ------------------------------ --------------- ---------------
SYS_LOB0000001021C00003$$                                     LOBSEGMENT                    8
I_ARGUMENT1                                                   INDEX                         8
VIEW$                                                         TABLE                         7
DEPENDENCY$                                                   TABLE                         7
I_OBJ2                                                        INDEX                         6
I_ARGUMENT2                                                   INDEX                         6
I_DEPENDENCY2                                                 INDEX                         6
I_DEPENDENCY1                                                 INDEX                         6
I_OBJ5                                                        INDEX                         6

已選擇20行。

參考:http://wwyz998.blog.163.com/blog/static/321867852011117111832334/
oracle移動數據文件
1.鏈接到數據庫
 [oracle@linux]$ sqlplus /nolog
 SQL> conn / as sysdba
2. 查看數據文件位置
SQL> select file_name from sys.dba_data_files;

SQL> select name from v$datafile;
FILE_NAME
------------------------------------------------------------------------
/oradata/PMPTGDB/users01.dbf
/oradata/PMPTGDB/undotbs01.dbf
/oradata/PMPTGDB/sysaux01.dbf
/oradata/PMPTGDB/system01.dbf
/oradata/PMPTGDB/work.dbf
 
2. 關閉數據庫
SQL> shutdown immediate;
 
4. 移動文件到新的位置(好比新的位置爲/media/hdd1/oradata/PMPTGDB )
cd /oradata/PMPTGDB/
mv users01.dbf undotbs01.dbf sysaux01.dbf system01.dbf work.dbf /media/hdd1/oradata/PMPTGDB 
 
5. 以mount模式啓動數據庫
SQL> startup mount;
SQL> alter database rename file   'C:\APP\WANGXW\ORADATA\ORCL\MYMOTIF_TS.DBF'   to   'D:\oradata\orcl\MYMOTIF_TS.DBF'; 
對每個要移動的文件重複執行上面的alter database rename file ... to ...
 
6. 打開數據庫
SQL> alter database open;
再次查看文件位置,發現已經更該。java

第 1 行出現錯誤:
ORA-01125: 沒法禁用介質恢復 - 文件 1 設置了聯機[url=]備份[/url]
ORA-01110: 數據文件 1: 'G:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSTEM01.DBF'linux

SQL>
是在歸檔模式下出現的問題, 
解決辦法是:sql

conn /  as sysdba
startup mount
recover datafile "select name from v$datafile;"  ;
alter databae open;
臨時表空間重建:
更多temp表空間維護可參考:http://www.blogjava.net/japper/archive/2012/06/28/381721.html數據庫

create temporary tablespace temp2 tempfile 'D:\oradata\orcl\temp1.DBF' size 50M autoextend off;
alter database default temporary tablespace temp2;
drop tablespace temp including contents and datafiles cascade constraints;


create temporary tablespace TEMP tempfile 'D:\oradata\orcl\TEMP01.DBF' size 50M autoextend on;
alter database default temporary tablespace TEMP;
drop tablespace temp2 including contents and datafiles cascade constraints;


------------------------------------------------------------------------------------------------------------------------------------------------------------api

UNDO 表空間重建(清理),釋放磁盤內存的辦法
原文:https://blog.csdn.net/sinat_27933301/article/details/80932226 
col FREE_RATE format a30
SELECT   a.tablespace_name,ROUND (a.total_size) "total_size(MB)",ROUND (a.total_size) - ROUND (b.free_size, 3) "used_size(MB)",ROUND (b.free_size, 3) "free_size(MB)",ROUND (b.free_size / total_size * 100, 2) || '%' free_rate  FROM   (  SELECT   tablespace_name, SUM (bytes) / 1024 / 1024 total_size FROM   dba_data_files GROUP BY   tablespace_name) a, (  SELECT   tablespace_name, SUM (bytes) / 1024 / 1024 free_size FROM   dba_free_space GROUP BY   tablespace_name) b WHERE   a.tablespace_name = b.tablespace_name(+);服務器

TABLESPACE_NAME      total_size(MB) used_size(MB) free_size(MB) FREE_RATE
-------------------- -------------- ------------- ------------- ------------------------------
SYSAUX                          720       636.062        83.938 11.66%
UNDOTBS1                        150       149.125          .875 .58%
USERS                             5         4.125          .875 17.5%
SYSTEM                          828       694.937       133.063 16.07%
EXAMPLE                         100         78.75         21.25 21.25%
MYMOTIF_TS                      100         4.437        95.563 95.56%oracle

確認文件:
select file_name,bytes/1024/1024 from dba_data_files where tablespace_name like 'UNDOTBS1';
檢查UNDO Segment狀態
select usn,xacts,rssize/1024/1024/1024,hwmsize/1024/1024/1024,shrinks from v$rollstat order by rssize;app

一、建立一個新的小空間的undo tablespace
create undo tablespace UNDOTBS2 datafile 'D:\oradata\orcl\UNDOTBS02.DBF' size 150m autoextend off;url

二、設置新的表空間爲系統undo_tablespace
alter system set undo_tablespace=UNDOTBS2;

3.等待原UNDO表空間全部UNDO SEGMENT OFFLINE 
  select usn,xacts,status,rssize/1024/1024/1024,hwmsize/1024/1024/1024,shrinks from v$rollstat order by rssize;
四、刪除舊的表空間
alter tablespace UNDOTBS1 offline;
drop tablespace UNDOTBS1 including contents and datafiles;
5.檢查空間狀況
     往後增長數據文件方法
ALTER TABLESPACE UNDOTBS2 ADD DATAFILE 'D:\oradata\orcl\UNDOTBS03.DBF' size 150M reuse AUTOEXTEND ON;

 詢回滾段狀況(原undo表空間的回滾段所有offline,能夠刪除相關表空間)
select tablespace_name,segment_name,status from dba_rollback_segs;
 
離線原undo表空間
alter tablespace undotbs1 offline;
 
肯定原undo回滾段所有offline,直接刪除
drop tablespace undotbs1 including contents and datafiles;

六、其餘方法 
  禁止undo tablespace自動增加
   alter database datafile 'C:\APP\WANGXW\ORADATA\ORCL\UNDOTBS01.DBF' autoextend off;
  擴大undo tablespace的大小:
   alter database datafile 'C:\APP\WANGXW\ORADATA\ORCL\UNDOTBS01.DBF' resize 200m;


  system表空間滿:
其解決的方法有兩個:
1)擴SYSTEM表空間,或者清理SYS.AUD$表;安裝數據庫時報以下錯誤:

ORA-00604:ERROR occurred at recursive SQL level 1
ORA-01653:unable to extend table SYS.AUD$ by 8192 in tablespace SYSTEM
ORA-02002:ERROR while writing to audit trail
ORA-00604:ERROR occurred at recursive SQL level 1
ORA-01653:unable to exten table SYS.AUD$ by 8192 in tablespace SYSTEM
WARNING:You are no longer connected to ORACLE.
SQL>SP2-0640:Not connected

報system系統表空間不足

能夠使用以下語句查詢system表空間中什麼對象佔用空間最大:

select SEGMENT_NAME,SEGMENT_TYPE,BYTES/1024/1024 from dba_segments where TABLESPACE_NAME='SYSTEM' and rownum < 10 order by BYTES/1024/1024 desc;

並對其進行分析,看system表空間過大的問題。


但如上顯示的錯誤信息已經直接說明:一是:數據庫的審計功能已經開啓(SYS.AUD$表,只有開了審計功能纔會向其中插入數據),如何開啓和關閉oracle數據庫中的審計功能?

擴展表空間能夠參考以下方法:

  方法一:手動重設並增長表空間tbsk的數據文件大小

      SQL> alter database datafile '/opt/oracle/oradata/ora11g/system.dbf' resize 20G;

  方法二:把表空間的數據文件設爲自動增加(不建議使用此方法)

      SQL> alter database datafile '/opt/oracle/oradata/ora11g/system.dbf' autoextend on next 10M maxsize unlimited;

      一個表空間數據庫文件最大能夠擴展到32G。

  方法三:增長新的數據文件(建議使用此方法)

      SQL> alter tablespace system add datafile '/opt/oracle/oradata/ora11g/system2.dbf' size 10G autoextend off;

 

下面語句清理審計表,釋放系統表空間:

sqlplus / as sysdba

truncate table SYS.AUD$;

 

2)關閉審計功能:(關閉審計須要從新啓動Oracle)

SQL> show parameter audit
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
audit_file_dest                      string      /oracle/app/admin/ora11g/adump
audit_sys_operations                 boolean     TRUE
audit_syslog_level                   string
audit_trail                          string      DB  -->說明已經開啓審計功能
SQL>

執行下面SQL:

SQL>alter system set audit_trail=none scope=spfile;

直接使用spfile文件中的審計功能參考audit_trail爲none,即關閉審計功能。

執行完後,重啓數據庫。

 

啓動後查看:

SQL> show parameter audit_trail

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
audit_trail                          string      NONE

 

SYSTEM表空間如今又能插入數據了。

 
原文連接:

oracle 刪除表空間及數據文件方法

oracle 關閉audit 功能

http://zxf261.blog.51cto.com/701797/762048

Oracle 11g缺省安裝數據庫啓動了audit功能,致使oracle不斷累積sys.aud$表及相關索引數據量增長;
若是致使表空間滿了,在alert日誌中將會報ORA-1654: unable to extend index SYS....錯誤。
若是不用到審計功能,建議關閉審計。

處理過程: 
一、用oracle用戶登陸到數據庫服務器,執行:
sqlplus / as sysdba
二、取消audit,將初始化參數audit_trail設置爲NONE
alter system set audit_trail=none scope=spfile;
三、而後重啓數據庫.
shutdown immediate;
sqlplus / as sysdba
startup;
四、刪除籤權數據,oracle用戶登陸到數據庫服務器:
sqlplus / as sysdba
truncate table SYS.AUD$;

關閉審計功能:
 sqlplus / as sysdba
 SQL> alter system set audit_trail=none scope=spfile;
 SQL> shutdown immediate;
 SQL> startup;
 SQL> truncate table SYS.AUD$;
相關文章
相關標籤/搜索