Saturday, October 12, 2019

Extract Index DDL from database export dump




PAR file for index ddl extract from dump using traditional import utility
===================================================================

userid= '/ as sysdba '
statistics=none
buffer=9999999
log=/oracle/export/IND/dump/imp_index_full_10122019.log
constraints=n
grants=n
rows=n
FROMUSER=HR
indexfile=/oracle/export/IND/dump/index3.sql
Tables=(EMPLOYEES)
file=(/oracle/export/IND//exp_full_IND.dmp)


To execute the command in background 
===========================================

nohup imp parfile=file_name.par &

Wednesday, October 9, 2019

Enable Trace in oracle for SID






Get SID :
================

column SID for a20
SELECT sys_context('USERENV', 'SID') SID FROM DUAL;


Enable Trace for SID  in oracle 
==================================


SQL> select username,sid,serial# from v$session where sid=22;

USERNAME                              SID    SERIAL#
------------------------------ ---------- ----------
SYS                                    22       2895

SQL>




alter session set tracefile_identifier='anurag_sql_trace';

SQL> EXEC DBMS_SYSTEM.set_sql_trace_in_session(sid=>22, serial#=>2895, sql_trace=>TRUE)

---To disable

SQL> EXEC DBMS_SYSTEM.set_sql_trace_in_session(sid=>123, serial#=>1234, sql_trace=>FALSE);

--- Get the tracefile name:

SELECT p.tracefile FROM   v$session s  JOIN v$process p ON s.paddr = p.addr WHERE  s.sid = 22;

TRACEFILE
------------------------------------------------------------------
/u01/app/oracle/diag/rdbms/db11g/db11g/trace/db11g_ora_9699.trc