Thursday, June 20, 2013

How to copy output of SQL commnads to a text file?

Steps to copy output of SQL commands to text file:

1. Go to SQL prompt:
  


2. Check Present working Directory:
     SQL> !pwd
               

3. create text file which will be saved at above location.
     SQL> spool priya.txt
       

4. After that execute your SQL command,  command & output will be saved in the text file you created.
   
    Note: you can execute as many command as you want  in that text file one after other.

5. Once your finished with your commands, close that text file.
    SQL> spool off;
 

6. Now check text file at the specified location.
  

7. Open that text file & check output.
    > cat priya.txt | more   
   

In this way we can save lengthy output of SQL command in text file.

    

Tuesday, June 11, 2013

Oracle Logs & Trace Files



Oracle logs & Trace Files:



1. Alert Log (alert_SID.log):

    Location: /oracle/SID/saptrace/background

    Log consist of instance activity such as startup, shutdown, switch logfile, parameter change, error etc.



2. Trace File (*.trc):

    2 types of Trace Files:

        System trace--> /oracle/SID/saptrace/background

        User Trace  --> /oracle/SID/saptrace/usertrace

    Normally the error logs globally mentioned in the alert log & more details are written in trace files.

    SQL> show parameter user_dump_dest;



3. Core Dump File:

    Location: /oracle/SID/saptrace/background

    Like core dump in OS. When there are issues related to configuration of OS such as, accessibility,
    oracle storage usually make core dump.

    SQL> show parameter core_dump_dest;


4. Audit File (ora_OSID.aud):

    It contains connection history from user sysdba (sys) & user audit activity for AUDIT_TRAIL = OS.

    If the file system, where audit_file_dest is full, we could not login with sysdba user (sys).

    SQL> show parameter audit_file_dest;



5. Network log (listener.log):

    Location : /oracle/SID/102_64/network/log

    Contains network related logs.