生产环境:AIX 5.3 + Oracle 10.2.0.5
任务要求:普通表改造分区表,历史数据不要
这个需求很简单:
pl/sql导出建表语句,依次修改成分区的建表语句,注意将索引修改成本地索引;
drop
原表;
create
新分区表.
1.重建过程中遇到问题:删除某表时报错ORA-00054,导致无法删除重建此表。
SQL> drop table MOD_RESALT_PERF_CARR_1X_ZTE;
create table MOD_RESALT_PERF_CARR_1X_ZTE(……)partition by ……(……);
create unique index …… on MOD_RESALT_PERF_CARR_1X_ZTE(……) local tablespace …… compress;ORA-00054: resource busy and acquire with NOWAIT specified
ORA-00955: name is already used by an existing object
ORA-14016: underlying table of a LOCAL partitioned index must be partitioned
2.查询造成此表锁定的会话。
SQL>
SQL> select t2.username , t2.sid, t2.serial#, t2.logon_time, t2.MACHINE, t2.PROGRAM
from v$locked_object t1, v$session t2
where t1.SESSION_ID=t2.SID and t1.object_id =
(select object_id
from user_objects
where object_name = ‘MOD_RESALT_PERF_CARR_1X_ZTE‘);USERNAME SID SERIAL# LOGON_TIME MACHINE PROGRAM
------------------------------ ---------- ---------- ----------- ---------------------------------------------------------------- ------------------------------------------------
FJCRNOP 596 39243 2014-5-27 1 fjcol8 JDBC Thin Client
3.查出的结果与现场开发维护人员确认,可以强制杀掉,但Oracle中kill
session遭遇ORA-00031。
SQL> alter system kill session ‘596,39243‘;alter system kill session ‘596,39243‘
ORA-00031: session marked for kill
此状态下,若drop 此表仍然会报错ORA-00054。
4.确定session对应的系统进程号SPID。
SQL> select a.spid,b.sid,b.serial#,b.username
from v$process a,v$session b
where a.addr=b.paddr and b.status=‘KILLED‘;SPID SID SERIAL# USERNAME
------------ ---------- ---------- ------------------------------
282882 596 39243 FJCRNOPSQL>
SQL> select spid, osuser, s.program
from v$session s,v$process p
where s.paddr=p.addr and s.sid=596;SPID OSUSER PROGRAM
------------ ------------------------------ ------------------------------------------------
282882 fjcrnop JDBC Thin Client
5.在数据库服务器上kill查出的系统进程:
[email protected]$uname -a
AIX cwwydb2 3 5 00C445A54C00
[email protected]$id
uid=500(oracle) gid=203(oinstall) groups=204(dba)
[email protected]$ps -ef|grep 282882
oracle 282882 1 2 13:08:01 - 4:12 oraclecwwydb2 (LOCAL=NO)
oracle 1274428 705422 0 17:16:07 pts/1 0:00 grep 282882
[email protected]$kill 282882
[email protected]$ps -ef|grep 282882
oracle 282882 1 2 13:08:01 - 4:12 oraclecwwydb2 (LOCAL=NO)
oracle 790910 705422 0 17:17:00 pts/1 0:00 grep 282882
[email protected]$kill -9 282882
[email protected]$ps -ef|grep 282882
oracle 282892 705422 0 17:17:17 pts/1 0:00 grep 282882
这里可以看到,kill没有杀掉进程,kill -9成功杀掉进程。
此时在数据库中可以看到,v$session视图下状态为killed的进程已经没有了。
SQL> select a.spid,b.sid,b.serial#,b.username from v$process a,v$session b where a.addr=b.paddr and b.status=‘KILLED‘;SPID SID SERIAL# USERNAME
------------ ---------- ---------- ------------------------------
6.再次运行删除表的脚本,成功执行,没有再报错。
SQL> @D:\jingyu\partitiontables\mod_resalt_perf_carr_1x_zte.tabTable dropped
Table created
Index created
Index created
Index created
SQL>
7.总结:遭遇ORA-00054可以找到造成锁定的会话,确认会话可以终止后,先在Oracle中kill
session,如果kill session遭遇ORA-00031,又需要立马清理,可以找到对应的系统进程在系统层面kill掉此进程。
记录一则ORA-00054,ORA-00031解决过程,布布扣,bubuko.com