Oracle imp exp 导入导出 执行脚本
一:用命令 imp/exp 的方式进行数据的导入和导出
一:文件后缀名:

二:oracle 导出 exp 命令
1 echo 开始备份数据库
2 if not exist D:\oracle_bak\files md D:\oracle_bak\files
3 if not exist D:\oracle_bak\logs md D:\oracle_bak\logs
4
5 set var=%date:~0,4%%date:~5,2%%date:~8,2%%time:~9,2%
6 exp GDSDCZJ/GDSDCZJ1234@192.168.1.100/pdborcl file=D:\oracle_bak\files\GDSDCZJ_%var%.dmp log=D:\oracle_bak\logs\GDSDCZJ_%var%.log
7 echo 备份数据库结束
8
9 echo 删除30天前的备份记录
10 forfiles /p "D:\oracle_bak" /s /m *.dmp /d -30 /c "cmd /c del @path"
11 forfiles /p "D:\oracle_bak" /s /m *.log /d -30 /c "cmd /c del @path"
12 echo 删除30天前的备份记录结束
13 exit
14
三:oracle 导入 imp 命令
1 echo 开始导入数据库
2 set var=%date:~0,4%%date:~5,2%%date:~8,2%
3 imp GDSDYTH/GDSDYTH@192.168.0.110/pdborcl full=y ignore=y file=D:\oracle_bak\files\gdsd_czj_%var%.dmp log=D:\oracle_bak\logs\gdsd_czj_to_apa_imp_%var%.log
4 echo 导入数据库结束
5 exit
6
四:oracle 删除用户 再创建用户并赋予相对应的操作权限,然后再 导入 imp 命令

1 drop user sync_plus_1_0501 cascade;
2 create user sync_plus_1_0501 identified by sync_plus_1_0501
3 default tablespace sync_plus_1 temporary tablespace temp quota 500m on users;
4 grant all privileges to sync_plus_1_0501 ;
5 grant ALLTAX to SYNC_PLUS_1_0501;
6 grant ALLINONE_JX to sync_plus_1_0501 ;
7 grant ALLOUTSIDE to sync_plus_1_0501 ;
8 grant dba to sync_plus_1_0501;
9 grant RDCX to sync_plus_1_0501;
10 quit;
11
1 echo 开始导入数据库
2 sqlplus sys/oracle@192.168.1.168/pdborcl as sysdba @F:\decoument\DB_soft\createUser.sql
3
4 set var=%date:~0,4%%date:~5,2%%date:~8,2%
5 imp sync_plus_1_0501/sync_plus_1_0501@192.168.1.168/pdborcl full=y ignore=y
6 file=F:\decoument\DB_soft\imp_data\SYNC_PLUS_1_%var%.dmp
7 log=F:\decoument\DB_soft\imp_data\logs\SYNC_PLUS_1_to_apa_imp_%var%.log
8 echo 导入数据库结束
9 exit;
执行 效果:

五:每天自动创建当天日期为后缀名的oracle用户。并给该用户导入数据
1:看执行效果
2:上脚本:
Imp_toDay_Data.bat
1 echo 开始导入数据库
2 set var=%date:~0,4%%date:~5,2%%date:~8,2%
3 sqlplus sys/oracle@192.168.1.168/pdborcl as sysdba @F:\decoument\DB_soft\imp_toDay_Data\createUser.sql
4
5 imp sync_plus_1_%var%/sync_plus_1_%var%@192.168.1.168/pdborcl full=y ignore=y file=F:\decoument\DB_soft\SYNC_PLUS_1_%var%.dmp log=F:\decoument\DB_soft\imp_toDay_Data\logs\SYNC_PLUS_1_to_apa_imp_%var%.log
6 echo 导入数据库结束
7createUser.sql
1 declare
2 v_time varchar(20);
3 v_sql varchar(4000);
4 v_count int :=0;
5 v_count_sql varchar(4000);
6 v_username varchar(300);
7 begin
8 select to_char(sysdate,'yyyyMMdd') into v_time from dual;
9 v_username :='SYNC_PLUS_1_'||v_time;
10 dbms_output.put_line(v_username);
11 SELECT count(USERNAME) into v_count FROM ALL_USERS t where t.username =v_username ;
12 dbms_output.put_line(v_count);
13 if v_count = 0 then
14 v_sql :='create user sync_plus_1_'||v_time ||' identified by sync_plus_1_'||v_time ||' default tablespace sync_plus_1 temporary tablespace temp quota 500m on users';
15 dbms_output.put_line(v_sql);
16 execute immediate v_sql;
17 end if;
18 v_sql:='grant all privileges to sync_plus_1_'||v_time ;
19 dbms_output.put_line(v_sql);
20 execute immediate v_sql;
21 v_sql:='grant ALLTAX to sync_plus_1_'||v_time;
22 dbms_output.put_line(v_sql);
23 execute immediate v_sql;
24 v_sql:='grant ALLINONE_JX to sync_plus_1_'||v_time ;
25 dbms_output.put_line(v_sql);
26 execute immediate v_sql;
27 v_sql:='grant ALLOUTSIDE to sync_plus_1_'||v_time ;
28 dbms_output.put_line(v_sql);
29 execute immediate v_sql;
30 v_sql:='grant dba to sync_plus_1_'||v_time;
31 dbms_output.put_line(v_sql);
32 execute immediate v_sql;
33 v_sql:='grant RDCX to sync_plus_1_'||v_time;
34 dbms_output.put_line(v_sql);
35 execute immediate v_sql;
36 commit;
37 end;
38 /
39
40 quit;
六: 对oracle数据库某个用户 进行删表后再导入数据

Imp_SYNC_PLUS_1.bat
1 echo 开始导入数据库
2 sqlplus /nolog @F:\decoument\DB_soft\imp_data\createUser.sql
3
4 set var=%date:~0,4%%date:~5,2%%date:~8,2%
5 imp SYNC_PLUS_1/SYNC_PLUS_1@192.168.1.168/pdborcl full=y ignore=y file=F:\decoument\DB_soft\SYNC_PLUS_1_%var%.dmp log=F:\decoument\DB_soft\imp_data\logs\SYNC_PLUS_1_to_apa_imp_%var%.log
6 echo 导入数据库结束
7 exit;
createUser.sql
--drop user sync_plus_1 cascade;
--create user sync_plus_1 identified by sync_plus_1 default tablespace sync_plus_1 temporary tablespace temp quota 500m on users;
--grant all privileges to sync_plus_1 ;
--grant ALLTAX to sync_plus_1;
---grant ALLINONE_JX to sync_plus_1 ;
--grant ALLOUTSIDE to sync_plus_1 ;
--grant dba to sync_plus_1;
--grant RDCX to sync_plus_1;
conn SYNC_PLUS_1/SYNC_PLUS_1@192.168.1.168/pdborcl ; ----禁用所有的外键
/*--批量生成规则
select 'alter table ' || table_name || ' disable constraint ' ||
constraint_name || ';'
from user_constraints
where constraint_type = 'R';
*/
SET SERVEROUTPUT ON SIZE 1000000
BEGIN
for c in (select 'ALTER TABLE '||TABLE_NAME||' DISABLE CONSTRAINT '||constraint_name||' ' as v_sql from user_constraints where CONSTRAINT_TYPE='R') loop
DBMS_OUTPUT.PUT_LINE(C.V_SQL);
begin
EXECUTE IMMEDIATE c.v_sql;
exception when others then
dbms_output.put_line(sqlerrm);
end;
end loop;
for c in (select 'ALTER TABLE '||TNAME||' DISABLE ALL TRIGGERS ' AS v_sql from tab where tabtype='TABLE') loop
dbms_output.put_line(c.v_sql);
begin
execute immediate c.v_sql;
exception when others then
dbms_output.put_line(sqlerrm);
end;
end loop;
end;
/
commit; ------禁用所有的主键;
/*
select 'alter table ' || table_name || ' disable constraint ' ||
constraint_name || ';'
from user_constraints
where constraint_type = 'P'; */
SET SERVEROUTPUT ON SIZE 1000000
BEGIN
for c in (select 'ALTER TABLE '||TABLE_NAME||' DISABLE CONSTRAINT '||constraint_name||' ' as v_sql from user_constraints where CONSTRAINT_TYPE='P') loop
DBMS_OUTPUT.PUT_LINE(C.V_SQL);
begin
EXECUTE IMMEDIATE c.v_sql;
exception when others then
dbms_output.put_line(sqlerrm);
end;
end loop;
for c in (select 'ALTER TABLE '||TNAME||' DISABLE ALL TRIGGERS ' AS v_sql from tab where tabtype='TABLE') loop
dbms_output.put_line(c.v_sql);
begin
execute immediate c.v_sql;
exception when others then
dbms_output.put_line(sqlerrm);
end;
end loop;
end;
/
commit; ----删除所有外键:
/*
select 'alter table ' || table_name || ' drop constraint ' ||
constraint_name || ';'
from user_constraints
where constraint_type = 'R';
*/ SET SERVEROUTPUT ON SIZE 1000000
BEGIN
for c in (select 'ALTER TABLE '||TABLE_NAME||' drop CONSTRAINT '||constraint_name||' ' as v_sql from user_constraints where CONSTRAINT_TYPE='R') loop
DBMS_OUTPUT.PUT_LINE(C.V_SQL);
begin
EXECUTE IMMEDIATE c.v_sql;
exception when others then
dbms_output.put_line(sqlerrm);
end;
end loop;
/*for c in (select 'ALTER TABLE '||TNAME||' DISABLE ALL TRIGGERS ' AS v_sql from tab where tabtype='TABLE') loop
dbms_output.put_line(c.v_sql);
begin
execute immediate c.v_sql;
exception when others then
dbms_output.put_line(sqlerrm);
end;
end loop;*/
end;
/
commit; ----删除主键:
/*
select 'alter table ' || table_name || ' drop constraint ' ||
constraint_name || ';'
from user_constraints
where constraint_type = 'P'; */ SET SERVEROUTPUT ON SIZE 1000000
BEGIN
for c in (select 'ALTER TABLE '||TABLE_NAME||' drop CONSTRAINT '||constraint_name||' ' as v_sql from user_constraints where CONSTRAINT_TYPE='P') loop
DBMS_OUTPUT.PUT_LINE(C.V_SQL);
begin
EXECUTE IMMEDIATE c.v_sql;
exception when others then
dbms_output.put_line(sqlerrm);
end;
end loop;
/*for c in (select 'ALTER TABLE '||TNAME||' DISABLE ALL TRIGGERS ' AS v_sql from tab where tabtype='TABLE') loop
dbms_output.put_line(c.v_sql);
begin
execute immediate c.v_sql;
exception when others then
dbms_output.put_line(sqlerrm);
end;
end loop;*/
end;
/
commit; -----删除所有表
--- 批量生成规则 select 'drop table '||table_name||';' from cat where table_type='TABLE' ; SET SERVEROUTPUT ON SIZE 1000000
BEGIN
for c in (select 'drop TABLE '||TABLE_NAME||' ' as v_sql from cat where table_type='TABLE') loop
DBMS_OUTPUT.PUT_LINE(C.V_SQL);
begin
EXECUTE IMMEDIATE c.v_sql;
exception when others then
dbms_output.put_line(sqlerrm);
end;
end loop;
/*for c in (select 'ALTER TABLE '||TNAME||' DISABLE ALL TRIGGERS ' AS v_sql from tab where tabtype='TABLE') loop
dbms_output.put_line(c.v_sql);
begin
execute immediate c.v_sql;
exception when others then
dbms_output.put_line(sqlerrm);
end;
end loop;*/
end;
/
commit; quit;
二:使用 PL/SQL 工具 进行数据的导入 导出
1: 前提:需要安装oracle Xe 的客户端

2: 使用Plsql 工具 进行demp 文件 的数据导入


——————————————————————————————————————————————————————————————————————————————————————————————————————
Oracle imp exp 导入导出 执行脚本的更多相关文章
- oracle imp exp 导入导出
一.exp导出 exp myuser/mypwd@orcl file=D:\sql-bak\myuser.dmp log=D:\sql-bak\myuser.log exp 用户/密码@实例名 fil ...
- oracle快速创建用户、imp/exp导入导出dmp文件
1.首先我们可以用管理员用户以sysdba的身份登录oracle sqlplus username/password as sysdba 2.然后我就可以来创建用户了. create user use ...
- 关于 Oracle 的数据导入导出及 Sql Loader (sqlldr) 的用法
在 Oracle 数据库中,我们通常在不同数据库的表间记录进行复制或迁移时会用以下几种方法: 1. A 表的记录导出为一条条分号隔开的 insert 语句,然后执行插入到 B 表中2. 建立数据库间的 ...
- oracle数据库数据导入导出步骤(入门)
oracle数据库数据导入导出步骤(入门) 说明: 1.数据库数据导入导出方法有多种,可以通过exp/imp命令导入导出,也可以用第三方工具导出,如:PLSQL 2.如果熟悉命令,建议用exp/imp ...
- Oracle 数据泵导入导出总结
Oracle 数据泵(IMPDP/EXPDP)导入导出总结 Oracle数据泵导入导出是日常工作中常用的基本技术之一,它相对传统的逻辑导入导出要高效,这种特性更适合数据库对象数量巨大的情形,因为我日常 ...
- Oracle之 dmp导入/导出、数据库操作等过程中的字符集问题
影响Oracle数据库字符集最重要的参数是NLS_LANG参数. 它的格式如下: NLS_LANG = language_territory.charset 它有三个组成部分(语言.地域和字符集),每 ...
- oracle数据库的导入 导出实例
oracle数据库的导入 导出实例 分类: DataBase2011-09-07 23:25 377人阅读 评论(0) 收藏 举报 数据库oraclefileusercmdservice 我要从另外一 ...
- oracle数据的导入导出(两种方法三种方式)
大概了解数据库中数据的导入导出.在oracle中,导入导出数据的方法有两种,一种是使用cmd命令行的形式导入导出数据,另一种是使用PL/SQL工具导入导出数据. 1,使用cmd命令行导入导出数据 1. ...
- ORACLE数据库在导入导出时序列不一致的问题
ORACLE数据库在导入导出时序列不一致的问题 在使用ORACLE数据库时,当给一个表设置自增字段时,我们经常会使用到序列+触发器来完成.但当你需要对数据库进行导入导出时,序列很容易出问题. 当你 ...
随机推荐
- 【游戏开发&Unity】捏脸系统(附源码)
本着“没有捏脸系统算什么RPG”的想法,着手做一个2d简易捏脸demo.其实换装游戏都差不多啦~ github代码地址:Simple-Character-Edit-System (Unity版本:5. ...
- Filter Authentication 登录认证
[编程式配置]可用webxml配置替换@WebListenerpublic class FilterListenerConfigurator implements ServletContextList ...
- 关于PHP中的全局变量global和$GLOBALS的不同区分
1.global Global的作用是定义全局变量,但是这个全局变量不是应用于整个网站,而是应用于当前页面,包括include或require的所有文件. 但是在函数体内定义的global变量,函数体 ...
- 007_Reverse Integer
###solution1####small data # def reverse(x): # res=[] # t=0 # p=1 #记录位数 # y=x # if x<0: # x=-x # ...
- oracle 利用over 查询数据和总条数,一条sql搞定
select count(*) over()总条数 ,a.*from table a
- renren-security旧版本 分模块 的模块之间关系浅析
Maven结构,一个父模块 六个子模块 七个pom.xml: \git\renren-security\pom.xml <modules> <module>renren-com ...
- (4)java数据结构--集合类及其数据结构归纳-有大图
Java集合类及其数据结构归纳 - s小小的我 - 博客园http://www.cnblogs.com/shidejia/p/6433788.html ---------大图可以 在新标签中打开图片 ...
- linux系统 户和账号操作
1,基本操作要求 实现用户账号的管理,要完成的工作主要有如下几个方面: · 用户账号的添加.删除与修改.· 用户口令的管理.· 用户组的管理. 2,用户账户添加删除 ...
- nginx使用https协议
效果: nginx添加ssl模块 ./configure --with-http_ssl_module 生成证书 openssl genrsa -out ca.key 2048 openssl req ...
- 【MongoDB】 Failed to connect to 127.0.0.1:27017, reason: Connection refused
由于项目需要,在一台虚拟机上安装了MongoDB,但是在启动的时候,出现如下错误: [root@localhost bin]# ./mongo MongoDB shell version v3.4.0 ...
