导入脚本如下:
@echo off setlocal set username=用户名 set password=密码 set bakdir=脚本路径 set sid=oracle服务实例名 set bakdate=dmp名称 set logdate=%date:~0,4%_%date:~5,2%_%date:~8,2% set connect=%username%/%password%@%sid% echo 生成 Oracle11g 删除脚本,请稍等…… sqlplus %connect% @%bakdir%scriptdropobj.sql echo 执行 Oracle11g 删除脚本,请稍等…… sqlplus %connect% @%bakdir%scriptdropobjall.sql echo 正在恢复 Oracle11g 数据库,请稍等…… imp %connect% file=%bakdir%chinatelecom_db_%bakdate%.dmp touser=用户名fromuser=来自谁导出人 log=%bakdir%oracle_imp_%logdate%.log ignore=y statistics=none buffer=100000000 endlocal pause
导出脚本如下
@echo off setlocal set username=用户名 set password=密码 set bakdir=路径 set sid=oracle服务名 set bakdate=%date:~0,4%%date:~5,2%%date:~8,2% set connect=%username%/%password%@%sid% echo 正在备份 Oracle11g 数据库,请稍等…… exp %connect% owner=用户名 buffer=64000000 file=%bakdir%chinatelecom_db_%bakdate%.dmp log=%bakdir%chinatelecom_db_%bakdate%.log endlocal
dropobj.sql脚本如下:
set heading off; set feedback off; spool E:oracle11g_bakscriptdropobjall.sql; prompt --Drop constraint select 'alter table '||table_name||' drop constraint '||constraint_name||' ;' from user_constraints where constraint_type='R'; prompt --Drop tables select 'drop table '||table_name ||';' from user_tables; prompt --Drop view select 'drop view ' ||view_name||';' from user_views; prompt --Drop sequence select 'drop sequence ' ||sequence_name||';' from user_sequences; prompt --Drop function select 'drop function ' ||object_name||';' from user_objects where object_type='FUNCTION'; prompt --Drop procedure select 'drop procedure '||object_name||';' from user_objects where object_type='PROCEDURE'; prompt --Drop package prompt --Drop package body select 'drop package '|| object_name||';' from user_objects where object_type='PACKAGE'; prompt --Drop database link select 'drop database link '|| object_name||';' from user_objects where object_type='DATABASE LINK'; select 'exit;' from dual; spool off; set heading on; set feedback on; exit;
dropobjall.sql脚本如下:
--Drop constraint --Drop tables drop table T_TEMP_3; --Drop view --Drop sequence --Drop function --Drop procedure --Drop package --Drop package body --Drop database link exit;
oralce 利用bat脚本导入导出dmp及一些表,函数,包,队列,连接删除的脚本也一并贴出来了,希望有用。