Recover the Oracle stored procedures' source code.

Links: http://www.dbatools.net/mydul/aul_sourcecode.html

    AUL just focus on the data recovery, it does not generate the source code of the stored procedures, but we can recover them. Just recover some kernel table's data and load them into new database, then run query to get them.

    Recover the following kernel tables.

unload table sys.user$ to sys_user.txt;
unload table sys.obj$ to sys_obj.txt;
set field_tag \x07
set record_tag \x06
unload table sys.source$ to sys_source.txt;

    Create the tables in new database.

@USER$_syntax.sql
@SOURCE$_syntax.sql;
@OBJ$_syntax.sql

    Load the data into new database, DON'T LOAD THEM INTO SYS SCHEMA.

sqlldr test/test crontrol=USER$_sqlldr.ctl
sqlldr test/test crontrol=OBJ$_sqlldr.ctl
sqlldr test/test crontrol=SOURCE$_sqlldr.ctl

    Run the following SQL to get the stored procedures' source code, packages' or types' also.

SELECT DECODE(S.LINE,1,'CREATE OR REPLACE ','')||SOURCE SOURCE
FROM
  USER$ U, OBJ$  O, SOURCE$ S
WHERE
  U.USER# = O.OWNER# AND
  O.OBJ# = S.OBJ# AND
  U.NAME = 'User Name'
  -- AND O.NAME = 'Procedure Name'
ORDER BY S.OBJ#, S.LINE

    You must have system tablespace for this, all the source codes are stored in SYSTEM tablespace.

Post a comment

« Previous | Main | Next »

Powered by
Movable Type 3.36