Code for adding the project to bookmarks

Add the project to del.icio.us

http://del.icio.us/post?title=www.memosoup.com&url=http://www.memosoup.com

Post a project on digg.com

http://digg.com/submit?phase=2&url=http://www.memosoup.com

Add the site to bookmarks:

function add2Bookmarks(title,url) {
if (window.sidebar) {
window.sidebar.addPanel(title, url,"");
} else if( document.all ) {
window.external.AddFavorite( url, title);
} else if( window.opera && window.print ) {
return true;
}
}



bookmark
Put this site to Your bookmarks

Usage of the temp tablespace in Oracle

First find the block size:


select value "BLOCK_SIZE"
from v$parameter
where name='db_block_size' ;

Now check the usage of the tablespace:

select
s.username "USER",s.sid,s.osuser,
u.tablespace "TS" ,
sum(u.blocks) * &BLOCK_SIZE./1024/1024 MB,
x.sql_text
from v$session s,v$sort_usage u,v$sqltext x
where s.saddr=u.session_addr
and s.sql_address=x.address
group by
s.sid, s.username, osuser,
tablespace, sql_text, address, piece
order by sid, piece asc;

Using pattern lists in Unix

Here is the small reminder about the syntax of the “case” command and the usage of the pattern lists.


#!/bin/ksh
print -n "Please enter the line: "
read line

case "$line" in
?(dog|cat) ) print "zero or one occurrence of any pattern" ;;
*(low|high) ) print "zero or more occurrences of any pattern" ;;
@(duncan|methos) ) print "exactly one occurrence of any pattern" ;;
+(rudolph|blitzen) ) print "one or more occurrence of any pattern" ;;
!(grinch|babay) ) print "everything except patterns" ;;
-@([hH?]) ) print "Some help..." ;;
-v*(erbose) ) print "Some more words..." ;;
*) print "Something else..." ;;
esac

Print the PATH directories in the readable format


echo $PATH| awk -v RS=":" '{ print $0 }'

echo $LD_LIBRARY_PATH |awk -v RS=":" '{ system ( "ls -rltd " $0 ) }'

Warning!
As far as the option ‘-v’ is used, the new awk(nawk in some systems) should be used.

To check if the new version of awk is installed:

awk 1 /dev/null

The output will be empty for new awk.
You have the old awk, if the output is something like

awk: syntax error near line 1

In this case nawk should be used instead awk

MS-DOS modification: echo %PATH% | awk -v RS=”;” “{ print $0 }”

Invalid objects in Oracle DB (health check)

Some standard queries to check the state of the Oracle DB

select 'alter '
|| decode(lower(object_type), 'package body','package',lower(object_type))
|| ' ' || owner || '.'
|| object_name
|| decode(object_type,'PACKAGE BODY', ' compile body;',' compile;') INVALID_OBJECTS
from DBA_OBJECTS
where STATUS = 'INVALID';

select 'ALTER INDEX '|| owner || '.' || index_name || ' rebuild online ;'
from dba_indexes where status = 'UNUSABLE'
union
select 'ALTER INDEX ' || index_owner || '.' || index_name
|| ' rebuild partition ' || partition_name || ' online ;'
from dba_ind_partitions
where status = 'UNUSABLE'
union
select 'ALTER INDEX ' || index_owner || '.' || index_name
|| ' rebuild subpartition ' || subpartition_name || ' online ;'
from dba_ind_subpartitions
where status = 'UNUSABLE';

SELECT name, unrecoverable_change# , unrecoverable_time
FROM v$datafile
order by 2;

Search for Oracle errors in the alert log

Search for Oracle errors in the last $NUM lines.


NUM=1000
SIGNAL_LIST='^(...-|Error|Starting.*instance)|terminating instance'

tail -$NUM alert_${ORACLE_SID}.log | awk '
BEGIN {prev="" ; ret=1 }
/'"$SIGNAL_LIST"'/ { if ( prev !~ /'"$SIGNAL_LIST"'/ ) { print "" ; print prev;} print $0;ret=0}
{prev=$0}
END { exit ret } '

On Unix Oracle alert log is normally located in bdump/alert_{ORACLE_SID}.log