Friday, September 16, 2011

du command

du -sh *
du -h --max-depth=1
du -k /u02 | sort -rn | less

screen command

$ screen
$ commands-here
(ctrl-a then ctrl-d) to detach
$ screen -r -ls (list screen session)
$ screen -r (to reattach to running screen session)

screen can be used to replace nohup

if you get error Cannot open your terminal '/dev/pts/1' - please check.
it is because you su to other user.

Try

sudo su - someuser
script /dev/null
screen

Thursday, September 8, 2011

AWR failed

when you can not run awr report because of awr is not initialized.
if you don't need old statistics.


run @?/rdbms/admin/catnoawr.sql
run @?/rdbms/admin/catawr.sql

shutdown immediate
startup

Wednesday, July 27, 2011

set up sqlplus environment

set serveroutput on size 1000000
set trimspool on
set long 5000
set linesize 120
set pagesize 9999
column plan_plus_exp format a80
set termout off
define gname=idle
column global_name new_value gname
select lower(user)||'@'||substr(global_name,1,
decode(dot,0,length(global_name),dot-1) ) global_name
from (select global_name, instr(global_name,'.') dot from global_name);
set sqlprompt '&gname> '
set termout on

if you have database with the same sid and global_name is not setup, you can include hostname in sqlplus prompt.


define _editor=vi
set serveroutput on size 1000000
set trimspool on
set long 5000
set linesize 100
set pagesize 9999
column plan_plus_exp format a80
--column global_name new_value gname
set termout off
define gname=idle
define hostname=idle
column global_name new_value gname
column host_name new_value hostname
select lower(user) || '@' || substr(global_name, 1,
  decode(dot,0, length(global_name), dot - 1) ) global_name
  from (select global_name, instr(global_name, '.') dot from global_name );
select  substr(host_name, 1,
  decode(dot,0, length(host_name), dot - 1) ) host_name
  from (select host_name, instr(host_name, '.') dot from v$instance );
set sqlprompt '&gname..&hostname> '
set termout on

above lines need be put into login.sql file
and the path to the login.sql file need be defined as SQLPATH environment

invlalid number error

When column type is VARCHAR2()

sometimes you can compare the column with a number in one table and sometimes not in another table.

It depends on the data in the column. If all the data stored in the column has only digit characters, you will be able to compare otherwise you will fail.

Wednesday, November 17, 2010

speed up sql execution

ALTER SESSION SET EVENTS '10520 TRACE NAME CONTEXT FOREVER, LEVEL 10';

ALTER SESSION SET EVENTS '10520 TRACE NAME CONTEXT OFF';

ORA-10520: recreate package/procedure/view only if definition has changed"

Since untouched package/procedure/view will not be recreated, it save time for processing lots of sql objects

manipulate txt file

replace tab with spaces

expand

or %s/^i/ /g in vi

input ^i by type ctrl +v +i
input ^m by type ctrl +v +m