Tuesday, January 25, 2011

Oracle : one liners needed by a DBA

Below is the reposirory of 1-liners (commands and some formatting) that we keep requiring most of the the time. I'll try to keep growing this repository

1. List datafile belonging to a tablespace
    set linesize 150
    set pagesize 200
    set echo off
    set verify off
    col file_name format a80
    select file_name , bytes/1024/1024 size_in_mb from dba_data_files where tablespace_name like upper('&1');

2. List all the data files.
    select name from v$datafile;

3. Versions:
     select * from v$version;
     select * from v$database;
     select * from product_component_version;
     select version from v$instance;
     select * from sys.gv_$version;
     select * from sys.product_component_version;
     select * from sys.sm_$version;
     select * from sys.gv_$instance;

4.  unzip Opatch to ORACLE_HOME
     unzip p6880880_112000_Linux-x86-64.zip -d $ORACLE_HOME
5.  Opatch Prereq Check
     opatch prereq CheckConflictAgainstOHWithDetail -ph ./
6. Apply patch
    opatch apply