You may append the 3 bytes to the file before exporting, it works for me . Before doing that system only work in Windows and HP -UX but failed in Linux.
FileOutputStream fStream = new FileOutputStream( f );
final byte[] bom = new byte[] { (byte) 0xEF, (byte) 0xBB, (byte) 0xBF };
OutputStreamWriter writer = new OutputStreamWriter( fStream, "UTF8" );
fStream.write( bom );
// writer to have your contents
Have a UTF-8 BOM (3 bytes, hex EF BB BF) at the start of the file. Otherwise Excel will interpret the data according to your locale's default encoding (e.g. cp1252) instead of utf-8
Wednesday, October 23, 2013
Friday, April 19, 2013
Dynamically Clean up the target Oracle DB
- This job will call a main script. This script will first call a pre-defiend SQL file by replacing the proper DB USERNAME.
SPOOL /home/tmp/drop.sqlselect'drop table '||owner ||'.'||table_name||' cascade constraint;'as LBL_SCRIPT from all_tables where owner = upper('#_dbuser_#');select'drop sequence '||sequence_owner||'.'||sequence_name||';'as LBL_SCRIPT from all_sequences where sequence_owner = upper('#_dbuser_#');select'drop PROCEDURE '||object_name||';'as LBL_SCRIPT from ALL_OBJECTS where OWNER = upper('#_dbuser_#') and OBJECT_TYPE IN ('PROCEDURE');select'drop FUNCTION '||object_name||';'as LBL_SCRIPT from ALL_OBJECTS where OWNER = upper('#_dbuser_#') and OBJECT_TYPE IN ('FUNCTION');SPOOL OFFexit - The script will then try to select out the table,sequence,procedure and function from the target DB and paste it into a sql file by executing the SQL file in previous step.
########################################## generate the drop scriptforexisting db#########################################function generate_drop_script{echo"generate the drop script"sqlplus $dbuser/$dbpassword@ORCL@$gropFileecho"remove unwanted lines int the drop script"sed -i -e's/[0-9]*.*row.*//ig'$finalDropFilesed -i -e's/LBL_SCRIPT//g'$finalDropFileecho"append exit command to the drop script"echo"exit;">> $finalDropFile} - The script will remove those unwanted characters/words from the generated sql file in previous step.
- Execute the generated sql file to clean up the DB.
Remotely run the dump file for Oracle
When we have TWO servers
- server 1 (client server )
- Platform - Linux Ret Hat
- Oracle - Client
- server 2 (host server - the target server host the DB) - Linux Ret Hat
- Platform - Linux Ret Hat
- Oracle - Full Version
The following are the suggested steps to achieve this.
- Ensure the client server's Oracle Client is Administrator Type. If not, please do re-run the runInstaller
- This to ensure the Oracle Client provide 'import' and 'export' services.
- Add the host server IP into client server's
- File name - host.allow
- E.g: /etc/host.allow
- Line to be added -> nfs: 10.116.1.123
- File name - hosts
- E.g: /etc/hosts
- 10.116.1.123 ORCL dbmain.company.com
- File name - host.allow
- Both server need to start the following services
- portmap
- netfs
- nfs
- E.g : $ /sbin/service nfs start
- Add the following line into file etc/exports
/home linux(rw,sync) linuxd600(rw,sync)/u01 10.116.1.123(rw,sync) - Must define the database address for establishing connection instead of pure text such as :-
$ imp host_user/host.com@'(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST='$DB_HOST')(PORT='$DB_PORT')))(CONNECT_DATA=(SID='$DB_SID')))'FILE=/get/dump/file/directory/dbdump.dmp FULL=y- Please define it in tnsnames.ora file E.g: /u01/app/oracle/product/11.2.0/client_1/network/admin/tnsnames.ora
ORCL=(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = dbmain.company.com)(PORT =1521)))(CONNECT_DATA =(SID = orcl))) - No need to restart listener as Oracle Client do not have such services being installed.
- Please define it in tnsnames.ora file E.g: /u01/app/oracle/product/11.2.0/client_1/network/admin/tnsnames.ora
- Set the proper environment variables
$ export ORACLE_HOME=/u01/app/oracle/product/11.2.0/client_1$ PATH=$PATH:$ORACLE_HOME/bin$ LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib; export LD_LIBRARY_PATH$ export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib - Now is the time to execute the dump file.
$ imp cnm_developerX/password@ORCLFILE=/get/dump/file/directory/dbdump.dmp FULL=y
Subscribe to:
Comments (Atom)
