1.先进行表分析(一定要执行此步,否则查询空表可能不准确)

select 'analyze table '||table_name||' compute statistics;' from user_tables;

2.再查询哪些表是空的(此步可以省略,直接进行第三步)

select table_name from user_tables where NUM_ROWS=0 order by table_name;

3.最后生成alert语句
select 'alter table '||table_name||' allocate extent;' from user_tables where num_rows=0 order by table_name;

4.导出表---通过PLSQL Developer(tools->Export Tables)导出。

5.导入时通过命令行(cmd)进行导入 imp user/pass@orcl file=E:\data\data.dmp full=y

6.导出序列和视图 ---通过PLSQL Developer(tools->Export User Objects,然后选择要导出的视图)导出。

7.导入序列和视图---将seq.sql和view.sql中的空间名替换掉,然后新建Command Window-->分别load两个文件导入执行即可。

*********************************另外一种导出方法*********************************

EXP和IMP是客户端工具程序,它们既可以在客户端使用,也可以在服务端使用。

EXPDP和IMPDP是服务端的工具程序,他们只能在ORACLE服务端使用,不能在客户端使用。

如果想导入的用户已经存在:
1. 导出用户 expdp user1/pass1 directory=dumpdir dumpfile=user1.dmp
2. 导入用户 impdp user2/pass2 directory=dumpdir dumpfile=user1.dmp REMAP_SCHEMA=user1:user2 EXCLUDE=USER

如果想导入的用户不存在:
1. 导出用户 expdp user1/pass1 directory=dumpdir dumpfile=user1.dmp
2. 导入用户 impdp system/passsystem directory=dumpdir dumpfile=user1.dmp REMAP_SCHEMA=user1:user2
3. user2会自动建立,其权限和使用的表空间与user1相同,但此时用user2无法登录,必须修改user2的密码

今天需要另一个数据库的用户表导入到当前库中,但用户名不相同,以前exp/imp时,可以指定fromuser和touser来解决,在expdp中也提供了类似的解决方法

impdp system/zlsoft dumpfile=expdp:EXPDP_ZLHIS.DMP nologfile=y tables=zlhis.dept remap_schema=zlhis:scott remap_tablespace=ZL9BASEITEM:users,zl9indexhis
:users,zl9indexmtl:users table_exists_action=truncate exclude=object_grant

几个重要参数的说明一下:

1、remap_user 重新映射用户,格式: source_user1:target_user1,source_user2:target_user2

2、remap_tablespace 重新映射表空间

3、 table_exists_action 表已经存在的动作 有效关键字: (SKIP), APPEND, REPLACE 和 TRUNCATE。

4、exclude=object_grant 跳过对象授权

****************第三种导出方法(常用)****************

exp scott/tiger@orcl file=D:\database.dmp

imp scott/tiger@orcl full=y file=D:\database.dmp

非本机:

imp user1/pass1@192.168.153.68:1521/orcl file=E:\data.dmp full=y

exp user1/pass1@192.168.153.68:1521/orcl file=E:\data.dmp full=y

参看:https://blog.csdn.net/mzd8341/article/details/76595772

这样导出的表可能不全,请先看文章开头如何执行 alter table table_name_xxx allocate extent;

*********************************导出部分表方法*********************************

exp scott/tiger@orcl  file=d:\test.dmp statistics=none TABLES=(TABLE1,TABLE2,TABLE3)

参看:https://blog.csdn.net/u011277123/article/details/53665302

oracle导出表的办法的更多相关文章

  1. 11g Oracle导出表 默认不导出数据为空的表解决

    11g oracle导出表时会默认不导出数据为空 1.Oracle11g默认对空表不分配segment,故使用exp导出Oracle11g数据库时,空表不会导出.  2.设置deferred_segm ...

  2. Oracle 导出表结构

    Oracle导出表结构 select A.Table_Name 表名 , -- A.column_name 字段名 A.column_name 字段名, A.data_type 数据类型, A.dat ...

  3. Oracle导出表(即DMP文件)的两种方法

    转载:http://blog.csdn.net/lanpy88/article/details/7580691   方法一:利用PL/SQL Developer工具导出: 菜单栏---->Too ...

  4. ORACLE 日常处理办法

    Oracle删除当前用户下所有的表的方法 1.如果有删除用户的权限,则可以: drop user user_name cascade; 加了cascade就可以把用户连带的数据全部删掉. 删除后再创建 ...

  5. PL/SQL不支持64位Oracle Client 解决办法

    解决X64操作系统PL/SQL连接报错问题 make sure you have the 32 bits oracle client installed 说明PLSQL Developer并不支持Or ...

  6. Oracle导出表数据与导入表数据dmp,以及导入导出时候常见错误

    使用DOS 操作界面导出表数据,导入表数据(需要在数据库所在的服务器上边执行) exp UserName/Password@192.168.0.141/orcl   file=d:\xtables.d ...

  7. 无法连接windows虚拟机oracle的解决办法

    在mac机上玩基于oracle db的开发真心不容易,oracle公司死活不出oracle express edition for mac OS,曾经发布过的oracle 10 for mac下载地址 ...

  8. oracle 导出表结构和数据,使用plsql

    比如说需要把A数据库里面的数据,导入到B数据库 准备工作:在B数据库中创建B数据库同名的的用户名和表空间,注意大小写必须一样. 1,导出表结构.A数据库里点击工具栏里的tools--Export Us ...

  9. Sqlserver通过链接服务器访问Oracle的解决办法

    转自http://blog.sina.com.cn/s/blog_614b6f210100t80r.html 一.创建sqlserver链接服务(sqlserver链接oracle)  首先sqlse ...

随机推荐

  1. 【哈希表】CODEVS1230 元素查找

    #include<cstdio> #include<vector> using namespace std; typedef vector<int>::iterat ...

  2. 【函数式权值分块】【分块】bzoj3196 Tyvj 1730 二逼平衡树

    #include<cstdio> #include<cmath> #include<algorithm> using namespace std; #define ...

  3. 【费马小定理+矩阵快速幂】HDU4549——M斐波那契数列

    [题目大意] M斐波那契数列F[n]是一种整数数列,它的定义如下:F[0] = aF[1] = bF[n] = F[n-1] * F[n-2] ( n > 1 )现在给出a, b, n,求出F[ ...

  4. [CF468D]Tree

    [CF468D]Tree 题目大意: ​ 一棵\(n(n\le10^5)\)个编号为\(1\sim n\)的点的带边权的树,求一个排列\(p_{1\sim n}\),使\(\sum dis(i,p_i ...

  5. Spring学习——DI(依赖注入)

    IOC容器,处理对象依赖关系 IOC与DI: IOC :是一个容器,创建对象的容器 DI :在容器创建对象后,处理对象的依赖关系,也叫依赖注入! 方式1:通过set方法注入值 可以给普通属性.集合属性 ...

  6. python内建datetime模块

    datetime 获取当前日期和时间 from datetime import datetime now = datetime.now() print(now) datetime转换为timestam ...

  7. Spring使用ComponentScan扫描Maven多模块工程的其它模块

    说明:在新建好了Maven多模块工程后,如果想要在其它模块也能使用Spring的对象管理,比如@Autowrited这些注入方式,那么就必须开启包扫描的功能才能使其进行注入到Spring的对象管理中. ...

  8. <摘录>Linux下动态共享库加载时的搜索路径详解

    对动态库的实际应用还不太熟悉的读者可能曾经遇到过类似“error while loading shared libraries”这样的错误,这是典型的因为需要的动态库不在动态链接器ld.so的搜索路径 ...

  9. .NET反编译

    http://www.cnblogs.com/powertoolsteam/archive/2011/01/05/1926066.html

  10. [Lync]lync同步通讯簿

    概述 在客户现场部署lync的时候,突然发现新安装的lync客户端,搜索联系人功能无法使用,而将lync客户端安装后,隔一段时间后,又可以查询了,发现可能是数据没有同步的原因. 解决方案 客户端地址簿 ...