Home Database Mysql Tutorial Oracle数据导入导出10g数据方法

Oracle数据导入导出10g数据方法

Jun 07, 2016 pm 05:45 PM
export data

分享一篇orace大数据量的导入导出方法我们利用了基于imp/exp命令 10g以上expdp/impdp命令 哦,有需要的朋友参考一下。

分享一篇orace大数据量的导入导出方法我们利用了基于imp/exp命令 10g以上expdp/impdp命令 哦,有需要的朋友参考一下。

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  导出表数据

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1666
14
PHP Tutorial
1273
29
C# Tutorial
1255
24
MySQL's Role: Databases in Web Applications MySQL's Role: Databases in Web Applications Apr 17, 2025 am 12:23 AM

The main role of MySQL in web applications is to store and manage data. 1.MySQL efficiently processes user information, product catalogs, transaction records and other data. 2. Through SQL query, developers can extract information from the database to generate dynamic content. 3.MySQL works based on the client-server model to ensure acceptable query speed.

Explain the role of InnoDB redo logs and undo logs. Explain the role of InnoDB redo logs and undo logs. Apr 15, 2025 am 12:16 AM

InnoDB uses redologs and undologs to ensure data consistency and reliability. 1.redologs record data page modification to ensure crash recovery and transaction persistence. 2.undologs records the original data value and supports transaction rollback and MVCC.

MySQL's Place: Databases and Programming MySQL's Place: Databases and Programming Apr 13, 2025 am 12:18 AM

MySQL's position in databases and programming is very important. It is an open source relational database management system that is widely used in various application scenarios. 1) MySQL provides efficient data storage, organization and retrieval functions, supporting Web, mobile and enterprise-level systems. 2) It uses a client-server architecture, supports multiple storage engines and index optimization. 3) Basic usages include creating tables and inserting data, and advanced usages involve multi-table JOINs and complex queries. 4) Frequently asked questions such as SQL syntax errors and performance issues can be debugged through the EXPLAIN command and slow query log. 5) Performance optimization methods include rational use of indexes, optimized query and use of caches. Best practices include using transactions and PreparedStatemen

MySQL vs. Other Programming Languages: A Comparison MySQL vs. Other Programming Languages: A Comparison Apr 19, 2025 am 12:22 AM

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages ​​such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages ​​have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

MySQL: From Small Businesses to Large Enterprises MySQL: From Small Businesses to Large Enterprises Apr 13, 2025 am 12:17 AM

MySQL is suitable for small and large enterprises. 1) Small businesses can use MySQL for basic data management, such as storing customer information. 2) Large enterprises can use MySQL to process massive data and complex business logic to optimize query performance and transaction processing.

How does MySQL index cardinality affect query performance? How does MySQL index cardinality affect query performance? Apr 14, 2025 am 12:18 AM

MySQL index cardinality has a significant impact on query performance: 1. High cardinality index can more effectively narrow the data range and improve query efficiency; 2. Low cardinality index may lead to full table scanning and reduce query performance; 3. In joint index, high cardinality sequences should be placed in front to optimize query.

MySQL for Beginners: Getting Started with Database Management MySQL for Beginners: Getting Started with Database Management Apr 18, 2025 am 12:10 AM

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA

MySQL vs. Other Databases: Comparing the Options MySQL vs. Other Databases: Comparing the Options Apr 15, 2025 am 12:08 AM

MySQL is suitable for web applications and content management systems and is popular for its open source, high performance and ease of use. 1) Compared with PostgreSQL, MySQL performs better in simple queries and high concurrent read operations. 2) Compared with Oracle, MySQL is more popular among small and medium-sized enterprises because of its open source and low cost. 3) Compared with Microsoft SQL Server, MySQL is more suitable for cross-platform applications. 4) Unlike MongoDB, MySQL is more suitable for structured data and transaction processing.

See all articles