导出

1.服务器上mkdir创建一个真实目录/home/oracle/dump

2.sqlplus /nolog

3.conn /as sysdba;

4.SQL> create directory data_dir as '/home/oracle/dump';

5.检查是否创建成功

select * from dba_directories;

6.用管理员用户给刚刚创建的虚拟目录赋权限

SQL> grant read,write on directory data_dir to user;

7.exit退出sql命令窗口执行导出动作

有五种导出方式:

    第一种:“full=y”,全量导出数据库;

expdp user/passwd@orcl dumpfile=expdp.dmp directory=data_dir full=y logfile=expdp.log;

    第二种:schemas按用户导出;

expdp user/passwd@orcl schemas=user dumpfile=expdp.dmp directory=data_dir logfile=expdp.log;

    第三种:按表空间导出;

expdp sys/passwd@orcl tablespace=tbs1,tbs2 dumpfile=expdp.dmp directory=data_dir logfile=expdp.log;

    第四种:导出表;

expdp user/passwd@orcl tables=table1,table2 dumpfile=expdp.dmp directory=data_dir logfile=expdp.log;

    第五种:按查询条件导;

expdp user/passwd@orcl tables=table1='where number=1234' dumpfile=expdp.dmp directory=data_dir logfile=expdp.

导入

首选切换数据库
export ORACLE_SID=bj;

然后sys连接数据库按照以下步骤操作:
1.创建临时表空间
create temporary tablespace TEMP_CPMDB_01 TEMPFILE '/u01/oradata/bj/tablespace/TEMP_CPMDB_01.DBF' size 256M autoextend on next 32M maxsize 2048m extent management local;
2.设置临时表空间为默认表空间
alter DATABASE default temporary tablespace TEMP_CPMDB_01;
3.创建表空间
create tablespace TSP_CPM logging datafile '/u01/oradata/bj/tablespace/TSP_CPM.DBF' size 3072M autoextend on next 32M maxsize unlimited extent management local;
4.创建用户
create user cpm identified by cpm account unlock default tablespace TSP_CPM TEMPORARY TABLESPACE TEMP_CPMDB_01;
5.授权
grant connect,resource to cpm;
grant dba to cpm;
6.创建目录
create directory imp_dir as '/tmp/importdata';
7.quit后导入数据
impdp cpm/cpm directory=imp_dir dumpfile=expdp_cpmdb_20170922.dmp logfile=impdp.log table_exists_action=replace;

用impdp命令导入,对应五种方式:

    第一种:“full=y”,全量导入数据库;

impdp user/passwd directory=data_dir dumpfile=expdp.dmp full=y;

    第二种:同名用户导入,从用户A导入到用户A;

impdp A/passwd schemas=A directory=data_dir dumpfile=expdp.dmp logfile=impdp.log;

    第三种:①从A用户中把表table1和table2导入到B用户中;

impdp B/passwdtables=A.table1,A.table2 remap_schema=A:B directory=data_dir dumpfile=expdp.dmp logfile=impdp.log;

        ②将表空间TBS01、TBS02、TBS03导入到表空间A_TBS,将用户B的数据导入到A,并生成新的oid防止冲突;

impdp A/passwdremap_tablespace=TBS01:A_TBS,TBS02:A_TBS,TBS03:A_TBS remap_schema=B:A FULL=Y transform=oid:n
directory=data_dir dumpfile=expdp.dmp logfile=impdp.log

    第四种:导入表空间;

impdp sys/passwd tablespaces=tbs1 directory=data_dir dumpfile=expdp.dmp logfile=impdp.log;

    第五种:追加数据;

impdp sys/passwd directory=data_dir dumpfile=expdp.dmp schemas=system table_exists_action=replace logfile=impdp.log;
--table_exists_action:导入对象已存在时执行的操作。有效关键字:SKIP,APPEND,REPLACE和TRUNCATE

oracle数据导出以及导入的更多相关文章

  1. 利用PL/SQL从Oracle数据库导出和导入数据

    转自:https://www.jb51.net/article/109768.htm 本文实例为大家分享了使用PL/SQL从Oracle数据库导出和导入数据的方法,供大家参考,具体内容如下 1.导出数 ...

  2. Oracle数据泵的导入和导出

    前言 今天王子要分享的内容是关于Oracle的一个实战内容,Oracle的数据泵. 网上有很多关于此的内容,但很多都是复制粘贴别人的,导致很多小伙伴想要使用的时候不能直接上手,所以这篇文章一定能让你更 ...

  3. oracle数据导出工具sqluldr2

    oracle数据导出工具sqluldr2可以将数据以csv.txt等格式导出,适用于大批量数据的导出,导出速度非常快.导出后可以使用oracle loader工具将数据导入.下载完sqluldr2,工 ...

  4. oracle如何导出和导入数据库表

    oracle如何导出和导入数据库表 oracle如何将项目中的表导出后在导入自己的数据库中,这是一个完整的操作,对于数据库备份或在本地查看数据验证数据进场用到,一般情况下我都用dos黑窗口进行操作,简 ...

  5. oracle如何导出和导入数据库/表

    oracle如何导出和导入数据库/表 oracle如何将项目中的表导出后在导入自己的数据库中,这是一个完整的操作,对于数据库备份或在本地查看数据验证数据进场用到,一般情况下我都用dos黑窗口进行操作, ...

  6. Oracle 数据导出到PowerDesigner

    原文:Oracle 数据导出到PowerDesigner [一]配置ODBC win7 :控制面板(查看方式:小图标)→管理工具→数据源(ODBC) 在[ODBC数据源管理器]面板下,在默认[用户DN ...

  7. memcached命令行、Memcached数据导出和导入、php连接memcache、php的session存储到memcached

    1.memcached命令行 telnet 127.0.0.1 11211set key2 0 30 2abSTOREDget key2VALUE key2 0 2abEND  如: set key3 ...

  8. memcached命令行、Memcached数据导出和导入

    1.memcached命令行 telnet 127.0.0.1 11211set key2 0 30 2abSTOREDget key2VALUE key2 0 2abEND  如: set key3 ...

  9. oracle表分区、表分析及oracle数据泵文件导入导出开心版

    1.先说oracle表分区是什么吧,这样吧我们来举个桃子,栗子太小,我们就不举了,我们来举个桃子. 你有500万份文件,你要把他存在磁盘上,好嘛,我们就一个文件夹,500万分文件在那儿杵着,我们想找到 ...

随机推荐

  1. [亲测哪步都不能省可用]联想ThinkPad E450装系统后开机一直停留在BootMenu上,无法选择硬盘进入

    1 重启电脑,开机时按F1进入BIOS:2 进入Security选项-->Secure Boot选择为Disabled:3 进入StartUp--UEFI/Legacy Boot 选项,UEFI ...

  2. winreg操作windows注册表详解示例

    #coding:utf-8 #=====================================================================#=====本程序演示了WINR ...

  3. Webpack 使用url-loader和file-loader打包资源文件

    在js中不仅可以通过import引入js文件,还可以引入图片.视频等资源文件,这样webpack打包时就会把所引入的资源文件也一起打包进来 打包进来的文件会返回一个字符串:即文件的路径 要做到这一点, ...

  4. nodeJs 使用 express-http-proxy 转发请求

    开发过程中经常需要用到 nodeJs做转发层 使用express配合 express-http-proxy 可以轻松的完成转发 使用过程: 安装 express-http-proxy npm inst ...

  5. rest_famework 增删改查初第三阶段(高级,此阶段是优化第二阶段的代码)的使用

    url: re_path('authors/$', views.AuthorView.as_view()), re_path('book/(?P<pk>\d+)/$', views.Boo ...

  6. 初探LaTeX

    第一次使用LaTeX 步骤  1 安装LaTeX 通过官网http://www.tug.org/mactex/mactex-download.html下载Mac版LaTeX. 安装成功后会出现 步骤 ...

  7. Redis 4.0.2.3 for Windows (alpha) 下载地址

    下载地址如下: https://github.com/tporadowski/redis/releases 如果直接使用redis-server.exe启动报错的话,就使用redis-server.e ...

  8. 如何在Chrome中导入和导出密码

    如果想让 Chrome 支持密码导入和导出,需要先在地址栏中执行  chrome://flags/#password-import-export  将该功能启用并重启浏览器才能生效. 浏览器重启完成后 ...

  9. C++字符串按照指定规则切割的功能模板类,常用的一段检测记录运行时间的代码

    template <typename T> struct vector_split { typedef typename std::vector<T>::iterator it ...

  10. Oracle 批量修改字段长度

    Oracle 批量修改字段长度 SELECT  'alter table '||a.table_name||' MODIFY  '||A.COLUMN_NAME||' VARCHAR2(100);' ...