Oracle Technology Blog

OraTech Blog provides tips,tricks,scripts and how-to type answers for Oracle related technologies. I use these commands very often, so I thought it would be useful to share with everybody. Please feel free to include your comments/corrections/questions.

Thursday, November 30, 2006

How to move LOB objects or partition to different tablespace

alter table SCHEMA1.LOB_TABLE move lob(lob_column) store as (tablespace lob_ts);

ALTER TABLE PartitionTableName MOVE PARTITION PartitionName TABLESPACE NewTableSpace

alter table move partition lob () store as ( tablespace
)

Gather Database Information systemstate and hanganalyze

#--------------------------------------------
# -- To capture Database information
#--------------------------------------------

# ---------------------------------------------------------------------------
# Put output in .out. Change as desired.
# Note: output directory requires write permission.
# ---------------------------------------------------------------------------

OUTF=${0}.out

# ---------------------------------------------------------------------------
# You may want to delete the output file so that backup information does
# not accumulate. If not, delete the following lines.
# ---------------------------------------------------------------------------

if [ -f "$OUTF" ]
then
rm -f "$OUTF"
fi

{ # output block

echo "`date` ----------------Beginning of Script------------"
echo "Script name: $0"
prstat 3 3
vmstat 1 3
ORACLE_SID=pnet11
ORACLE_BASE=/opt/oracle
ORACLE_HOME=/opt/oracle/product/9.2.0
PATH=./:$ORACLE_HOME/bin:/usr/ccs/bin:/usr/bin:/usr/sbin:/usr/local/bin
LD_LIBRARY_PATH=$ORACLE_HOME/ctx/lib:$ORACLE_HOME/lib:/usr/openwin/lib:/usr/dt/lib
export ORACLE_SID ORACLE_BASE ORACLE_HOME PATH LD_LIBRARY_PATH
umask 022
STAMP=`date "+%Y%m%d"`
INFO1="Started at `date`"
x=`dekr /opt/oracle/scripts/dba/.Schedulejobs/perf.dat`
sqlplus perfstat/$x << eof
spool utllockt.log
@/opt/oracle/product/9.2.0/rdbms/admin/utllockt.sql
set lines 130 pages 500
select * from gv\$lock;
col machine format a30
select machine,username,count(*) from gv\$session where status='ACTIVE' group by machine,username;
spool off
exit;
eof
echo "`date` ----------------Beginning of systemstate------------"
sqlplus "/ as sysdba" << eof
oradebug setmypid
oradebug unlimit
oradebug dump systemstate 10
exec dbms_lock.sleep(90);
oradebug dump systemstate 10
exec dbms_lock.sleep(90);
oradebug dump systemstate 10
exit;
eof
echo "`date` ----------------Beginning of hanganalyze------------"
sqlplus "/ as sysdba" << eof
oradebug setmypid
oradebug setinst all
oradebug -g def hanganalyze 10
exec dbms_lock.sleep(120);
oradebug -g def hanganalyze 10
exec dbms_lock.sleep(120);
oradebug -g def hanganalyze 10
exit;
eof
echo "`date` ----------------Beginning of RACDIAG------------"
sqlplus perfstat/$x << eof
@racdiag.sql
@tfsmlock.sql
@tfsclock.sql
@tfslkill.sql
@v_views.sql
exit;
eof
prstat
vmstat 1 3
echo "`date` ----------------End of Script------------"
} >> $OUTF

Text Index Creation

Text Index Creation or interMedia Index creation or textindex

spool logs/imindex_attachment.log
drop index HIBM_COMMENTARY.MKTATTACHMENTS_ATTACHMENT;
execute ctx_adm.set_parameter('log_directory', '/opt/oracle/sami/imindex/logs');
execute CTX_OUTPUT.END_LOG;
execute ctx_output.start_log('mkt_attachments.log');
execute ctx_adm.set_parameter('max_index_memory', '600M');
execute ctx_ddl.drop_preference('mystore1');
execute ctx_ddl.create_preference('mystore1', 'BASIC_STORAGE');
execute ctx_ddl.set_attribute('mystore1', 'I_TABLE_CLAUSE','tablespace INDEX_TS storage (initial 5M)');
execute ctx_ddl.set_attribute('mystore1', 'K_TABLE_CLAUSE','tablespace INDEX_TS storage (initial 5M)');
execute ctx_ddl.set_attribute('mystore1', 'R_TABLE_CLAUSE','tablespace INDEX_TS storage (initial 5M)');
execute ctx_ddl.set_attribute('mystore1', 'N_TABLE_CLAUSE','tablespace INDEX_TS storage (initial 5M)');
execute ctx_ddl.set_attribute('mystore1', 'I_INDEX_CLAUSE','tablespace INDEX_TS storage (initial 5M)');
execute ctx_ddl.set_attribute('mystore1', 'P_TABLE_CLAUSE','tablespace INDEX_TS storage (initial 5M)');
CREATE INDEX HIBM_COMMENTARY.mktattachments_attachment ON HIBM_COMMENTARY.MKT_ATTACHMENTS (attachment)
INDEXTYPE IS CTXSYS.CONTEXT
PARAMETERS ('datastore DIRECT_DATASTORE storage mystore1 filter ctxsys.inso_filter')
PARALLEL 4;
alter index HIBM_COMMENTARY.dr$MKTATTACHMENTS_ATTACHMENT$x rebuild nocompress;
execute CTX_OUTPUT.END_LOG;
spool off;

RMAN Catalog Query

RMAN Catalog Query
===================
alter session set nls_date_format='DD-MON-YY HH24:MI:SS';

col handle format a50
select HANDLE,START_TIME,COMPLETION_TIME,status,concur
from RC_BACKUP_PIECE
where DB_ID=(select dbid from v$database)
and COMPLETION_TIME >= sysdate-3
order by COMPLETION_TIME