AUL just focus on the data recovery, it does not generate the SQL of creating the indexes, 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;
unload table sys.ind$ to sys_ind.txt;
unload table sys.icol$ to sys_icol.txt;
unload table sys.col$ to sys_col.txt;
Create the tables in new database.
@USER$_syntax.sql
@OBJ$_syntax.sql
@IND$_syntax.sql
@ICOL$_syntax.sql
@COL$_syntax.sql
Load the data into new database, DON'T LOAD THEM INTO SYS SCHEMA.
sqlldr test/test control=USER$_sqlldr.ctl
sqlldr test/test control=OBJ$_sqlldr.ctl
sqlldr test/test control=IND$_sqlldr.ctl
sqlldr test/test control=ICOL$_sqlldr.ctl
sqlldr test/test control=COL$_sqlldr.ctl
Then run the following SQL to get the SQL of createing the indexes, you must add the UNIQUE keyword for unique indexes manually, else you can rewrite the SQL. And run the query on Oracle 9i or above because of SYS_CONNECT_BY_PATH function call.
SELECT
'CREATE INDEX '||I.NAME||' ON '||T.NAME||'('||IDX.PATH||');' INDEX_DDL
FROM
USER$ U, OBJ$ T, OBJ$ I,
(
select I.BO#, I.OBJ#, C.POS#,
SUBSTR(sys_connect_by_path(CN.NAME,','),2) path
from IND$ I, ICOL$ C, COL$ CN
WHERE I.OBJ# = C.OBJ# AND I.BO# = C.BO#
AND I.BO# = CN.OBJ# AND C.COL# = CN.INTCOL#
start with C.POS#=1
connect by PRIOR I.OBJ# = I.OBJ#
AND prior C.POS# = C.POS# - 1 ) IDX,
(SELECT I.BO#, I.OBJ#, COUNT(*) COLCNT
FROM ICOL$ I GROUP BY I.BO#, I.OBJ#) IDXC
WHERE
U.USER# = T.OWNER# AND
IDX.BO# = T.OBJ# AND
IDX.OBJ# = I.OBJ# AND
IDX.BO# = IDXC.BO# AND
IDX.OBJ# = IDXC.OBJ# AND
IDX.POS# = IDXC.COLCNT AND
U.NAME = 'User Name'
ORDER BY T.NAME, I.NAME
You must have system tablespace for this, all the source codes are stored in SYSTEM tablespace.
