有朋友在ITPUB问到一个问题,如何resize一个SYSTEM表空间。
从常规来说,假如我们希望resize一个文件,这个文件能够resize的部分必然是没有数据,未被使用的,也就是说,我们需要找到一个文件最高的Extent号,这个Extent之外的空间是可以被resize的,以下一个查询可以帮我们找到一个文件最末端的对象:
col segment_name for a30
col owner for a10
SELECT *
FROM (SELECT owner, segment_name,segment_type,block_id, blocks
FROM dba_extents
WHERE tablespace_name = 'SYSTEM' and file_id='&fileid'
ORDER BY block_id DESC)
WHERE ROWNUM < 11;
看一下我的一个数据库:
SQL> col segment_name for a30
SQL> col owner for a10
SQL> SELECT *
2 FROM (SELECT owner, segment_name,segment_type,block_id, blocks
3 FROM dba_extents
4 WHERE tablespace_name = 'SYSTEM' and file_id='&fileid'
5 ORDER BY block_id DESC)
6 WHERE ROWNUM < 11;
Enter value for fileid: 1
old 4: WHERE tablespace_name = 'SYSTEM' and file_id='&fileid'
new 4: WHERE tablespace_name = 'SYSTEM' and file_id='1'
OWNER SEGMENT_NAME SEGMENT_TYPE BLOCK_ID BLOCKS
---------- ------------------------------ ------------------ ---------- ----------
SYS EYGLE_IP TABLE 25609 128
SYS EYGLE_IP TABLE 25481 128
SYS EYGLE_IP TABLE 25353 128
SYS I_H_OBJ#_COL# INDEX 25305 8
SYS TEST TABLE 25297 8
SYS I_TEST INDEX 25289 8
SYS TEST TABLE 25281 8
SYS T TABLE 25273 8
SYS EYGLE_IP TABLE 25265 8
SYS EYGLE_IP TABLE 25257 8
10 rows selected.
我们注重到高水位上有些索引是可以通过rebuild来改变其位置的,但是在正常模式下,Oracle不答应rebuild这些索引:
SQL> alter index I_H_OBJ#_COL# rebuild;
alter index I_H_OBJ#_COL# rebuild
*
ERROR at line 1:
ORA-00701: object necessary for warmstarting database cannot be altered
有两种方式可以使得这些对象答应被重建:
1.通过migrate模式
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup migrate;
ORACLE instance started.
Total System Global Area 139531744 bytes
Fixed Size 452064 bytes
Variable Size 121634816 bytes
Database Buffers 16777216 bytes
Redo Buffers 667648 bytes
Database mounted.
Database opened.
SQL> alter index I_H_OBJ#_COL# rebuild;
Index altered.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 139531744 bytes
Fixed Size 452064 bytes
Variable Size 121634816 bytes
Database Buffers 16777216 bytes
Redo Buffers 667648 bytes
Database mounted.
Database opened.
2.通过一个内部事件
SQL> alter system set event='38003 trace name context forever, level 10' scope=spfile;
System altered.
SQL> startup force;
ORACLE instance started.
Total System Global Area 139531744 bytes
Fixed Size 452064 bytes
Variable Size 121634816 bytes
Database Buffers 16777216 bytes
Redo Buffers 667648 bytes
Database mounted.
Database opened.
SQL> alter index i_h_obj#_col# rebuild;
Index altered.
38003事件的作用是:CBO Disable column stats for the dictionary objects in recursive SQL
也就是说可以将部分对象从启动的bootstrap$需要里剥离出来,从而可以被在线rebuild.
这个事件能够影响的对象很有限,这类操作也是极其危险的,所以不在这里具体列出。
-The End-
http://www.eygle.com/archives/2007/02/ora_00701_warmstarting.Html