Friday, June 4, 2010

Useful Unix-Linux commands for apps DBA’s

  • Search a word on a text(s)
find . -type f -name “*.txt” -exec grep XXWW {} \; -print

  • Number of files in a directory:
ls -l | wc -l

  • Kill all processes of a user (be careful !)
kill `ps -fu username | awk ‘NR != 1 {print $2}’`

  • Find a file under current directory and subdirectories
find . -name “*.trc”

  • Find files older than XX days (60 days)
find . -name “*.trc” -mtime +60

  • Find files older than XX days and move them to another directory.
find . -name “*.trc” -mtime +60 -exec mv {} /data1/test \

  • Find files older than XX days and delete them all (be careful)
find . -name “*.trc” -mtime +60 -exec rm {} \;

  • Runing Apache services
ps -ef|grep apache

  • Running Concurrent processes
ps -ef|grep FNDLIBR*|grep user

  • Running forms services
ps -ef|grep f60*|grep user

Tuesday, June 1, 2010

table import with Oracle SQL Loader (sqlldr)

Samlpe sql loader command:

sample 1:
sqlldr \'SYS/password AS SYSDBA\' control=/data1/dump/control2.ctl log=/data1/dump/test2.log

sample 2:
sqlldr userid=xxx/xxx control=/data01/DEV/control.ctl log=/data01/DEV/test.log




control file content:

OPTIONS (SKIP=0)
LOAD DATA
INFILE "/data1/dump/XXX_TABLE_NAME.txt"
BADFILE "/data1/dump/aaa.bad"
DISCARDFILE "/data1/dump/aaa.dsc"
TRUNCATE

INTO TABLE "XXX"."TABLE_NAME"
FIELDS TERMINATED BY "|"
trailing nullcols
(
SOURCE_SYSTEM_KEY CHAR(4000),
NAME_SURNAME CHAR(4000),
WORK_TEL CHAR(4000),
MOBILE_TEL CHAR(4000),
EMAIL CHAR(4000),
STATE CHAR(4000),
CITY CHAR(4000),
SSN CHAR(4000),
SSN2 CHAR(4000),
SEX CHAR(4000),
DATE_OF_BIRTH CHAR(4000),
NOTES CHAR(4000),
ADRESS CHAR(4000),
SOURCE_SYSTEM2 CHAR(200)
)