批处理bat删除Oracle用户下所有的表,并从另外一数据库导入新数据

title YBW_ebyrc8-更新数据库
@echo off

(
echo set feedback off heading off term off 
echo set pages 0 trim on trims on lines 32767 long 999999 
echo set echo off
echo spool ebyrc8_dropTable.sql 
echo select 'Alter table '^|^|TABLE_NAME^|^|' '^|^|'drop constraint'^|^|' '^|^| CONSTRAINT_NAME^|^|';'  from user_constraints where CONSTRAINT_TYPE ^='R';
echo select 'drop table ' ^|^| TABLE_NAME ^|^| ' ' ^|^| ';'  from user_tables;
echo spool off 
echo exit  
) > ebyrc8_delTableTmp.sql

sqlplus ebyrc8/ebyrc8@10.0.0.21:1521/orcl  @"%~dp0ebyrc8_delTableTmp.sql" 
del "%~dp0ebyrc8_delTableTmp.sql"
echo exit >> ebyrc8_dropTable.sql 
sqlplus ebyrc8/ebyrc8@10.0.0.21:1521/orcl  @"%~dp0ebyrc8_dropTable.sql" 
del "%~dp0ebyrc8_dropTable.sql"
echo ebyrc8/ebyrc8@10.0.0.21:1521/orcl 删除完成
timeout 1

set /a t1=%time:~0,2%
if %t1% LSS 10 set t1=0%t1%

timeout 1
set dmpFilePath=E:\软件\YBW\ps\YBW_ebyrc8_%date:~0,4%-%date:~5,2%-%date:~8,2%_%t1%%time:~3,2%%time:~6,2%.dmp
exp ebyrc8/ebyrc8@10.0.0.81:1521/orcl file=%dmpFilePath% log=%dmpFilePath%.exp.log direct=y owner=ebyrc8
timeout 5
imp ebyrc8/ebyrc8@10.0.0.21:1521/orcl file=%dmpFilePath% log=%dmpFilePath%.imp.log full=y ignore=y

 

 

 

posted @ 2017-09-18 17:03  Sring65  阅读(630)  评论(0编辑  收藏  举报