主题:如何Oracle编译失效的包体
作者:基毛飞上天
情况说明:在吗?可以帮忙重新编译一个包吗?我们这边编译不了!
处理思维:
(1)包头失效还是包体失效?
(2)是否存在阻碍的进程影响重新编译?
(3)如果存在阻碍,与应用人员沟通,是否可以尝试杀Process以及会话
1. 查看包头和包体是否失效?
从以下SQL语句输出得知,包头没有失效,包体失效了
目前创新互联已为近千家的企业提供了网站建设、域名、网络空间、网站托管、服务器托管、企业网站设计、红河网站维护等服务,公司将坚持客户导向、应用为本的策略,正道将秉承"和谐、参与、激情"的文化,与客户和合作伙伴齐心协力一起成长,共同发展。
BEGIN pkg_test.ap_get_baTran(200,20180515); END;
-
SQL> SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY_CURSOR(to_char('7b4dpss4k3hc5'),NULL));
-
-
PLAN_TABLE_OUTPUT
-
--------------------------------------------------
-
SQL_ID 7b4dpss4k3hc5, child number 0
-
BEGIN pkg_test.ap_get_baTran(200,20180515); END;
-
NOTE: cannot fetch plan for SQL_ID: 7b4dpss4k3hc5, CHILD_NUMBER: 0
-
Please verify value of SQL_ID and CHILD_NUMBER;
-
It could also be that the plan is no longer in cursor cache (check v$sql_plan)
7. 杀会话
经与应用人员沟通,可以尽情地杀会话,以及PROCESS(这个需要本地杀)
-
alter system kill session '12481,8711';
8. 再次查看是否有独占编译包体的锁
检查出1719 ZJDB PKG_TEST Body Exclusive None,还是存在独占DDL锁的进程。按照以上的方式,杀1719的会话,是不对的!因为这个会话就是SYS用户正在执行重新编译的语句。不可能杀掉重新编译的语句嘛,所以看下还能从什么方面下手!
-
SQL> select * from dba_ddl_locks where name='PKG_REPORT';
-
-
SESSION_ID OWNER NAME TYPE MODE_HELD MODE_REQU
-
---------- --------------- ---------------- ------------------------- --------- ---------
-
9710 ZJDB PKG_TEST Table/Procedure/Type Null None
-
948 ZJDB PKG_TEST Table/Procedure/Type Null None
-
10155 ZJDB PKG_TEST Table/Procedure/Type Null None
-
6814 ZJDB PKG_TEST Table/Procedure/Type Null None
-
2851 ZJDB PKG_TEST Table/Procedure/Type Null None
-
21183 ZJDB PKG_TEST Table/Procedure/Type Null None
-
14698 ZJDB PKG_TEST Table/Procedure/Type Null None
-
16963 ZJDB PKG_TEST Table/Procedure/Type Null None
-
23503 ZJDB PKG_TEST Table/Procedure/Type Null None
-
2650 ZJDB PKG_TEST Table/Procedure/Type Null None
-
20671 ZJDB PKG_TEST Table/Procedure/Type Null None
-
1719 ZJDB PKG_TEST Body Exclusive None
-
9710 ZJDB PKG_TEST Body Null None
-
20671 ZJDB PKG_TEST Body Null None
-
6814 ZJDB PKG_TEST Body Null None
-
16963 ZJDB PKG_TEST Body Null None
-
21183 ZJDB PKG_TEST Body Null None
-
948 ZJDB PKG_TEST Body Null None
-
2851 ZJDB PKG_TEST Body Null None
-
10155 ZJDB PKG_TEST Body Null None
-
23503 ZJDB PKG_TEST Body Null None
-
2650 ZJDB PKG_TEST Body Null None
-
14698 ZJDB PKG_TEST Body Null None
-
23 rows selected.
9. 找出ZJDB.PKG_TEST对应ddl锁的相关信息
找出ZJDB.PKG_TEST对应的DDL锁的SID与会话SID符合的会话,机器名字和用户名字以及状态
-
SQL> select b.saddr, b.sid, b.serial#,b.process,b.status,b.username, b.MACHINE from v$session b where b.sidin
-
( Select b.sid From dba_ddl_locks a, v$session b Where a.session_id = b.SID and a.name = 'PKG_TEST' and owner='ZJDB')
-
order by b.username desc;
-
-
SADDR SID SERIAL# PROCESS STATUS USERNAME MACHINE
-
---------------- ---------- ---------- ---------- -------- --------- ---------
-
070000A02BB0E7E0 1719 30765 37358470 ACTIVE SYS RACZJ-DB1
-
070000A010BFF958 10155 46885 33227250 ACTIVE ZJDB RACZJ-DB1
-
070000A00CB32110 9710 9641 27525876 ACTIVE ZJDB RACZJ-DB1
-
070000A023BC4438 2032 9479 31195338 ACTIVE ZJDB RACZJ-DB1
-
070000A0061E8210 23503 30787 55313168 ACTIVE ZJDB RACZJ-DB1
-
070000A0279C9920 948 44781 13631706 ACTIVE ZJDB RACZJ-DB1
-
070000A02B9B4FC0 893 27923 54263886 ACTIVE ZJDB RACZJ-DB1
-
070000A02BCA68C8 2650 48113 29033334 ACTIVE ZJDB RACZJ-DB1
-
070000A00DE3DE58 21183 59867 43516348 ACTIVE ZJDB RACZJ-DB1
-
070000A015A40440 18410 50345 3998656 ACTIVE ZJDB RACZJ-DB1
-
070000A009727FB0 16963 33555 66847560 ACTIVE ZJDB RACZJ-DB1
-
070000A023D20C00 2851 17117 10224286 ACTIVE ZJDB RACZJ-DB1
-
070000A02FB62590 1776 28699 46334786 ACTIVE ZJDB RACZJ-DB1
-
070000A015E08488 20671 38781 53150014 ACTIVE ZJDB RACZJ-DB1
-
070000A011386AF0 14698 60901 37421588 ACTIVE ZJDB RACZJ-DB1
-
070000A005CC69A8 20416 37977 30147116 ACTIVE ZJDB RACZJ-DB1
-
070000A001EE7AC0 21745 60937 8192734 ACTIVE ZJDB RACZJ-DB1
-
17 rows selected.
10. 操作系统层面杀process
--以sid=10155为例子,杀系统的process,这个杀process的操作,一般是在他们的主机杀process!
-
SQL> select sid, SERIAL#,process,status from v$session where sid=10155;
-
-
SID SERIAL# PROCESS STATUS
-
---------- ---------- ------------------------ --------
-
10155 30765 37358425 ACTIVE
-
-
$ ps -ef|grep 37358425
-
$ kill -9 37358425 --操作系统层面杀会话
-
$ ps -ef|grep 37358452
12. 数据库层面杀会话
-
alter system kill session '10155,46885';
-
alter system kill session '9710,9641';
-
alter system kill session '2032,9479';
-
alter system kill session '23503,30787';
-
alter system kill session '948,44781';
-
alter system kill session '893,27923';
-
alter system kill session '2650,48113';
-
alter system kill session '21183,59867';
-
alter system kill session '18410,50345';
-
alter system kill session '16963,33555';
-
alter system kill session '2851,17117';
-
alter system kill session '1776,28699';
-
alter system kill session '20671,38781';
-
alter system kill session '14698,60901';
-
alter system kill session '20416,37977';
-
alter system kill session '21745,60937';
13. 查看创建包体的命令是否成功
-
SQL> alter package ZJDB.PKG_TEST compile body;
-
Package body altered.
14. 相关链接
http://www.itpub.net/forum.php?mod=viewthread&tid=1761963
https://blog.csdn.net/u011146687/article/details/72808565
当前文章:包对象之Oracle如何编译失效包体
本文路径:
http://cdkjz.cn/article/jichdg.html