Parm Patram

Oracle, Linux and UNIX tips, tricks and stuff
  • Home
  • Site Map
  • See long running jobs in the RAC

    RMAN, SQL & PL/SQL, SQLPLUS 08-10-2011 Comments Off

    column
    select inst_id,opname, totalwork, sofar, time_remaining from gv$session_longops where totalwork > sofar order by time_remaining;

  • NLS date format

    HEADS UP, SQL & PL/SQL, SQLPLUS 02-11-2011 Comments Off
    ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY HH24:MI:SS';
    
  • see tag on raw devices (oracle asm)

    ASM (Automatic Storage Magement), SQL & PL/SQL, SQLPLUS 01-10-2011 Comments Off

    cat /dev/raw/raw46 | od -a -N128

  • Run SQL commands from shell script

    SQL & PL/SQL, SQLPLUS, Scripts 11-15-2010 Comments Off

    #!/bin/bash

    #
    # login to database and run a query

    SQL_HOME=WHERE
    LOG_HOME=WHERE
    SQL_USER=WHAT
    SQL_PASS=WHAT
    SQL_HOST=WHAT
    SQL_DB=WHAT
    SQL_PORT=1521
    LOGFILE=${SQL_HOME}/output.log

    SQL_LOGIN_STR=”${SQL_HOME}/sqlplus -S ${SQL_USER}/${SQL_PASS}@${SQL_HOST}:${SQL_PORT}/${SQL_DB} ”

    cd $SQL_HOME

    RESULT=`${SQL_LOGIN_STR} << EOF
    SET HEADING OFF
    SELECT NAME FROM V\\$DATABASE;
    exit;
    EOF`

    if [ $RESULT == $SQL_DB ]; then
    echo `date`”: OK: $RESULT” | sed ’s/\n//g’ >> $LOGFILE
    else
    echo `date`”: Got Error: $RESULT” | sed ’s/\n//g’ >> $LOGFILE
    fi

  • Write CLOB data to file using UTL_FILE

    SQL & PL/SQL, SQLPLUS 04-28-2010 Comments Off

    http://www.idevelopment.info/data/Oracle/DBA_tips/LOBs/LOBS_41.shtml

  • Showing object compilation errors.

    SQL & PL/SQL, SQLPLUS 03-15-2010 Comments Off

    set wrap on
    set pages 20
    set lin 200
    column name format A25
    column type format A15
    column seq format 9999
    colunn line format 9999
    column pos format 999
    column text format A100
    select name,type,sequence seq,line,position pos,text from dba_errors where owner=’OWNER’ order by type,name;

  • Identify invalid online redo logs

    REDO LOGS, SQLPLUS 05-04-2009 Comments Off

    select group#,l.sequence#,archived,l.status running, lf.status os_status,member from v$log l join v$logfile lf using(group#) order by group#;

    NOTES:

    • The STATUS column of v$logfile (os_status) is NOT refreshed in real-time. Information is updated on log switch.
  • Get block_size for a datafile

    DBVERIFY, SQLPLUS 05-01-2009 Comments Off

    You may need to get the block size of a datafile before running dbv (DBVERIFY) on it. The following will do this in sqlplus:

    set wrap off
    select t.name tablespace, file#, d.name datafile, block_size BS from v$datafile d join v$tablespace t using (ts#);

  • Equivalent of mysql limit clase for sqlplus

    SQL & PL/SQL, SQLPLUS 11-17-2008 Comments Off
    SELECT a, b, c
    FROM
    ( SELECT a, b, c, ROWNUM rn
      FROM
      ( SELECT a, b, c FROM RECORD
        WHERE AVAIL='Y"
        ORDER BY DATE DESC
      )
      WHERE ROWNUM <= 25
    )
    WHERE rn >= 21;
    
    This clunky code is the equivalent of mysql's elegant:
    select a,b,c from record limit 5 offset 4;
  • Command line history/editing for sqlplus (rlwrap)

    HEADS UP, Linux, SQLPLUS 11-11-2008 Comments Off

    install rlwrap (available from http://utopia.knoware.nl/~hlub/rlwrap/)

    then add this to the bash_profile:

    alias sqlplus=’rlwrap sqlplus’

« Previous Entries

Category:

  • Administration
    • ASM
    • BLOCK SIZE
    • Database Recovery
    • DBVERIFY
    • GRANTS
    • OEM
    • REDO LOGS
  • APPS
    • AutoConfig
    • Change EBS IP Address
    • Cloning
    • DB Environment Vars
    • Discoverer
    • Environment Vars
    • Patching
    • Problems
    • Resources Online
    • Tricks & Tips
    • Upgrading
    • Workflow
  • Articles
  • Backup & Recovery
  • Certification
  • Configuration
  • DATABASE STRUCTURE
    • Data Dictionary
    • Logical Database Structure
    • Physical Database Structure
    • SCHEMA
  • DATAGUARD
  • Documentation
    • ASM (Automatic Storage Magement)
    • Command Reference
    • DataPump
    • Documentation Library
    • SQL Developer
  • EBS
  • Enterprise Manager
  • FLASHBACK
  • HACKING
  • HEADS UP
  • Installation
    • RAC
  • JDeveloper
  • Linux
    • iptables
    • Networking
  • Monitoring
    • Big Brother
  • MQ
  • NFS
  • NXclient/server
  • Online Resources
  • PERL
  • python
  • RMAN
    • RMAN Catalog Setup
  • Routing & Switching
  • SAN – NAS
    • Netapp
  • Scripts
  • Serial-Parallel-Port-Testers
  • SNMP
  • Software
  • Solaris
  • Spiritual
  • SQL & PL/SQL
  • SQLPLUS
  • Startup/Shutdown
  • Streams
  • Tuning
    • INDEXES
    • SQL Tuning
      • TKPROF and sql_trace
  • Version Control
  • Vertias
    • VCS
    • VxFS
  • VMWare
  • VNC
  • Windows XP
  • ZFS
© Blogname. All Rights Reserved. Entries RSS Comments RSS Login Open Source