`

about oracle data imp and exp

阅读更多

Oracle数据导入导出 imp/exp就相当于oracle数据还原与备份。exp命令可以把数据从远程数据库服务器导出到本地的dmp文件,imp命令可以把dmp文件从本地 导入到远处的数据库服务器中。 利用这个功能可以构建两个相同的数据库,一个用来测试,一个用来正式使用。

 

执行环境:可以在SQLPLUS.EXE或者DOS(命令行)中执行,

DOS中可以执行时由于 在oracle 8i 中 安装目录ora81BIN被设置为全局路径,

该目录下有EXP.EXE与IMP.EXE文件被用来执行导入导出。

oracle用java编写,SQLPLUS.EXE、EXP.EXE、 IMP.EXE这两个文件有可能是被包装后的类文件。

SQLPLUS.EXE调用EXP.EXE、IMP.EXE所包裹的类,完成导入导 出功能。

 

下面介绍的是导入导出的实例。

数据导出

1 将数据库TEST完全导出,用户名system 密码manager 导出到D:\daochu.dmp中

exp system/manager@TEST file=d:\daochu.dmp full=y

2 将数据库中system用户与sys用户的表导出

exp system/manager@TEST file=d:\daochu.dmp owner=(system,sys)

3 将数据库中的表inner_notify、notify_staff_relat导出

exp aichannel/aichannel@TESTDB2 file= d:\datanewsmgnt.dmp tables=(inner_notify,notify_staff_relat)

4 将数据库中的表table1中的字段filed1以"00"打头的数据导出

exp system/manager@TEST file=d:\daochu.dmp tables=(table1) query=" where filed1 like '00%'"

 

上面是常用的导出,对于压缩,既用winzip把dmp文件可以很好的压缩。

也可以在上面命令后面 加上 compress=y 来实现。

 

数据导入

1 将D:\daochu.dmp 中的数据导入 TEST数据库中。

imp system/manager@TEST file=d:\daochu.dmp

imp aichannel/aichannel@TEST full=y file=d:\datanewsmgnt.dmp ignore=y

上面可能有点问题,因为有的表已经存在,然后它就报错,对该表就不进行导入。

在后面加上 ignore=y 就可以了。

2 将d:daochu.dmp中的表table1 导入

imp system/manager@TEST file=d:\daochu.dmp tables=(table1)

 

基本上上面的导入导出够用了。不少情况要先是将表彻底删除,然后导入。

 

注意:

操作者要有足够的权限,权限不够它会提示。

数据库时可以连上的。可以用tnsping TEST 来获得数据库TEST能否连上。

 

附录一:

给用户增加导入数据权限的操作

第一,启动sql*puls

第二,以system/manager登陆

第三,create user 用户名 IDENTIFIED BY 密码 (如果已经创建过用户,这步可以省略)

第四,GRANT CREATE USER,DROP USER,ALTER USER ,CREATE ANY VIEW ,

DROP ANY VIEW,EXP_FULL_DATABASE,IMP_FULL_DATABASE,

DBA,CONNECT,RESOURCE,CREATE SESSION TO 用户名字

第五, 运行-cmd-进入dmp文件所在的目录,

imp userid=system/manager full=y file=*.dmp

或者 imp userid=system/manager full=y file=filename.dmp

 

执行示例:

F:WorkOracle_Databackup>imp userid=test/test full=y file=inner_notify.dmp

 

屏幕显示

Import: Release 8.1.7.0.0 - Production on 星期四 2月 16 16:50:05 2006

(c) Copyright 2000 Oracle Corporation. All rights reserved.

 

连接到: Oracle8i Enterprise Edition Release 8.1.7.0.0 - Production

With the Partitioning option

JServer Release 8.1.7.0.0 - Production

 

经由常规路径导出由EXPORT:V08.01.07创建的文件

已经完成ZHS16GBK字符集和ZHS16GBK NCHAR 字符集中的导入

导出服务器使用UTF8 NCHAR 字符集 (可能的ncharset转换)

. 正在将AICHANNEL的对象导入到 AICHANNEL

. . 正在导入表 "INNER_NOTIFY" 4行被导入

准备启用约束条件...

成功终止导入,但出现警告。

 

 

附录二:

Oracle 不允许直接改变表的拥有者, 利用Export/Import可以达到这一目的.

先建立import9.par,

然后,使用时命令如下:imp parfile=/filepath/import9.par

例 import9.par 内容如下:

FROMUSER=TGPMS

TOUSER=TGPMS2 (注:把表的拥有者由FROMUSER改为TOUSER,FROMUSER和TOUSER的用户可以不同)

ROWS=Y

INDEXES=Y

GRANTS=Y

CONSTRAINTS=Y

BUFFER=409600

file==/backup/ctgpc_20030623.dmp

log==/backup/import_20030623.log

 

在导入导出命令中加上feedback=1000可以让过程显示一个不断增多的 “...”,以改变以往的闪烁的光标

New:

exp/imp已经很好用了,但是唯一的确定是速度太慢,如果1张表的数据有个百千 万的,常常导入导出就长时间停在这个表这,但是从Oracle 10g开始提供了称为数据泵新的工具expdp/impdp,它为Oracle数据提供高速并行及大数据的迁移。

imp/exp可以在客户端调用,但是expdp/impdp只能在服务端,因为在 使用expdp/impdp以前需要在数据库中创建一个Directory

create directory dump_test as '/u01/oracle10g';

grant read, write on directory dump_test to piner

然后就可以开始导入导出

expdp piner/piner directory=dump_test dumpfile=user.dmp 导出用户的数据

expdp piner/piner directory=dump_test dumpfile=table.dmp tables=test1,test2 导出表数据

impdp piner/piner directory=dump_test dumpfile=user.dmp 导入该用户数据

impdp piner/piner directory=dump_test dumpfile=table.dmp 导出表数据

分享到:
评论

相关推荐

    Data Science Using Oracle Data Miner and Oracle R Enterprise [2016]

    Data Science Using Oracle Data Miner and Oracle R Enterprise: Transform Your Business Systems into an Analytical Powerhouse English | 8 Feb. 2017 | ISBN: 1484226135 | 289 Pages | PDF | 12.99 MB ...

    Oracle Clusterware Administration and Deployment Guide

    在进行Oracle Clusterware的管理与部署时,需要遵循Oracle提供的官方指南《Oracle Clusterware Administration and Deployment Guide》。这份文档不仅适用于Oracle的资深用户,也对那些希望学习如何部署和管理Oracle...

    Swift Data Structure and Algorithms [2016]

    Find out about Swift generators and sequences, and see how to use them to implement advanced data structures such as Stack, StackList, Queue, and LinkedList Implement sorting algorithms such as ...

    Python Data Structures and Algorithms [2017]

    Python Data Structures and Algorithms by Benjamin Baka English | 30 May 2017 | ASIN: B01IF7NLM8 | 310 Pages | AZW3 | 6.63 MB Key Features A step by step guide, which will provide you with a thorough...

    Hands-On Data Structures and Algorithms with Rust.epub

    Chapter 4, Lists, Lists, and More Lists, covers the first data structures: lists. Using several examples, this chapter goes into variations of sequential data structures and their implementations. ...

    Oracle Database Backup and Recovery User's Guide.pdf

    ### Oracle数据库备份与恢复用户指南知识点解析 #### 一、Oracle数据库备份与恢复概述 - **备份的重要性**:Oracle数据库备份对于确保数据安全至关重要。它能够帮助组织在遇到硬件故障、软件错误或灾难性事件时...

    Hands-On Data Science and Python Machine Learning

    In 2012, I left to start my own successful company, Sundog Software, which focuses on virtual reality environment technology, and teaching others about big data analysis. Table of Contents Getting ...

    Swift.Data.Structure.and.Algorithms

    by-step guide Develop native Swift data structures and algorithms for use in mobile, desktop, and server-based applications Learn about performance efficiency between different data structures and ...

    Data.Science.and.Big.Data.Analytics

    Data Science and Big Data Analytics is about harnessing the power of data for new insights. The book covers the breadth of activities and methods and tools that Data Scientists use. The content ...

    Java 9 Data Structures and Algorithms

    Java 9 Data Structures and Algorithms by Debasish Ray Chawdhuri English | 28 Apr. 2017 | ASIN: B01KM5RLGS | 340 Pages | AZW3 | 4.28 MB Key Features This book provides complete coverage of reactive ...

    Data.Structures.and.Algorithms.Made.Easy.epub

    "Data Structures And Algorithms Made Easy: Data Structure And Algorithmic Puzzles" is a book that offers solutions to complex data structures and algorithms. There are multiple solutions for each ...

    Data Driven: Harnessing Data and AI to Reinvent Customer Engagement

    Using the latest technologies―cloud, mobile, social, internet of things (IoT), and artificial intelligence (AI)―we have more data about consumers and their needs, wants, and affinities than ever ...

    Oracle Security

    Chapter 1 Oracle and Security What’s It All About? The Oracle Security Model Procedures, Policies, and Plans If I Had a Hammer... Chapter 2 Oracle System Files What’s in the Files? The ...

    Oracle Database Sample Schemas 12.2c

    Schema HR – Division Human Resources tracks information about the company employees and facilities. Schema OE – Division Order Entry tracks product inventories and sales of company products through ...

    Oracle Application Express: Build Powerful Data-Centric Web Apps with APEX

    Oracle Application Express: Build Powerful Data‐Centric Web Apps lays out basic information about APEX concepts before delving into the unparalleled power of the platform and describing the new ...

Global site tag (gtag.js) - Google Analytics