Posts

Showing posts from September, 2011

linux send mail with attachment

Hi All, This blog depicts - configure files regarding send mail service - collect an output from sql - send that output to recipients through mail (office domain) configuration of send mail service file: install the rpm of send mail up the service "service sendmail restart" vi /etc/mail/submit.cf D{MTAHost}[192.168.x.x] --this will be the smtp ip then save and quit service sendmail restart collect an output from sql This is very simple that you all can generate. Also this link is very useful to do that http://www.oracle-base.com/articles/misc/OracleShellScripting.php send that output to recipients through mail (office domain) Okay now is the most important part. To attach that file and send it echo | mutt -a list_"$CURR_TIME".txt -s FileName_"$CURR_TIME" x@y.com,z@y.com < mail_body.txt Here the attachment file name is list_"$CURR_TIME".txt This is a technique to zip a directory in linux without using tar. I have used as I have to send

SQL Loader with dynamic control file generation

Hi All, Now what i am writing, I believe many of new bees will require it while using sqlldr for ETL or any other data loading issue. The thing is while loading using sqlldr there is no option to enter the source file name in that table. So what I have done I just create a dynamic control file which generates before loading of each source file. Here I have used two scripts 1) proc1: for filtering files and running a loop. Every source file will be processed in this loop. 2) another procedure proc2 which is called by proc1 to perform load operation proc1 ------- while (( $i < $filecounter )); do echo "file number $i" ### Take the first File FILENAME=`ls -l *.txt|head -1|awk -F' ' '{print $9}'` dos2unix $FILENAME ### if filename exists already continue the loop ### FINDSQLSCRIPT="select 'COUNT:'||count(*) from TBLBRACSUMMARY where file_name='$FILENAME';" OUTPUT_FILECOUNT=`/app/u01/oracle/prod

RMAN recovery in another host and renaming DBNAME

Precaution: ----------- 1. Be sure that your oracle user on destination host is owned by "dba" secondary group and "oinstall" primary group other wise you will get RMAN-04005: error from target database: ORA-01031: insufficient privileges 2. Create a password file Steps to restoration: --------------------- ----- untar the file containing backup pieces tar -zxvf /app/u02/oradata/full_rman_backup_190911.tar.gz copy all archivelog (near date of full backup) to archiveloglocation ----- mount the database with control file export ORACLE_SID=orcl rman target / nocatalog set dbid xxxxxxxxx startup nomount pfile='/app/u01/oracle/product/10.2.0/db_1/dbs/initorcl.ora' restore controlfile from '/app/u03/oradata/full_rman_backup_190911/o1_mf_s_762246924_77f5xflw_.bkp'; alter database mount; ---- check the datafile, logfile information and find the scn number sqlplus / as sysdba select group#, to_char(first_change#), status, archived from v$log order

Consistent IMPDP

First select all the parent table of your desired exported tables. select parent.owner || '.' || parent.table_name "Parent table", 'is parent of' " ", child.owner || '.' || child.table_name "Child table" from dba_constraints child join dba_constraints parent on child.r_constraint_name = parent.constraint_name and child.r_owner = parent.owner where lower(child.table_name) in ( 'tblmcu', 'tblmcup', 'tblmcuy', 'tbltacc', 'tbltdebitdocument'); ------------- Find the distinct table name if you want select distinct (aa.Parent_table) from ( select ''''||parent.table_name||''',' Parent_table from dba_constraints child join dba_constraints parent on child.r_constraint_name = parent.constraint_name and child.r_owner = parent.owner where lower(child.table_name) in ( 'tblmcu', 'tblmcup&