oracle sy imp,Oracle中Exp/imp用法介绍

本文部分内容摘录自网络,感谢网友的经验总结;

一.说明

oracle

的exp/imp命令用于实现对数据库的导出/导入操作;

exp命令用于把数据从远程数据库服务器导出至本地,生成dmp文件;

imp命令用于把本地的数据库dmp文件从本地导入到远程的Oracle数据库中。

二.使用示例

3.1 数据导出:

1 将数据库LMIS完全导出,用户名dacg 密码dacg 导出到E:\lmis.dmp中

exp dacg/dacg@lmis file=E:\lmis.dmp full=y

direct=y

说明:DIRECT参数将告诉EXP直接读取数据,而不像传统的EXP那样,使用SELECT来读取表中的数据,

这就减少了SQL语句处理过程。一般也建议使用。不过有些情况下DIRECT参数是无法使用的。

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

exp dacg/dacg@lmis file=E:\lmis.dmp

owner=(system,sys)

3 将数据库中的表 TableA,TableB 导出

exp

dacg/dacg@lmis file=E:\lmis.dmp

tables=(TableA,TableB)

4 将数据库中的表tableA中的字段filed1 值为 "九州通" 的数据导出

exp dacg/dacg@lmis file=E:\lmis.dmp

tables=(tableA) query='where filed1='王五''

说明: compress=y

用来对导出文件进行压缩,FULL,这个用于导出整个数据库,在ROWS=N一起使用时,可以导出整个数据库的结构

1 将备份数据库文件中的数据导入指定的数据库lmis中,如果 lmis

已存在该表,则不再导入;

imp dacg/dacg@lmis file=E:\lmis.dmp full=y

ignore=y

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

imp dacg/dacg@lmis file=E:\lmis.dmp

tables=(table1)

3. 导入一个完整数据库

imp dacg/dacg@lmis

file=E:\lmis.dmp,log=E:\lmis.log full=y ignore=y

4. 导入一个或一组指定用户所属的全部表、索引和其他对象

imp dacg/dacg@lmis

file=E:\lmis.dmp,log=E:\lmis.log fromuser=seapark

imp dacg/dacg@lmis

file=E:\lmis.dmp,log=E:\lmis.log

fromuser=(seapark,amy,amyc,harold)

5. 将一个用户所属的数据导入另一个用户

imp dacg/dacg@lmis

file=E:\lmis.dmp,log=E:\lmis.log fromuser=seapark

touser=seapark_copy

imp dacg/dacg@lmis

file=E:\lmis.dmp,log=E:\lmis.log fromuser=(seapark,amy)

touser=(seapark1, amy1)

6. 导入一个表

imp dacg/dacg@lmis

file=E:\lmis.dmp,log=E:\lmis.log fromuser=seapark TABLES=(a,b)

7. 使用参数文件

imp dacg/dacg@lmis

parfile=bible_tables.par

说明:bible_tables.par参数文件:

8. 增量导入

imp dacg/dacg@lmis inctype= RECTORE FULL=Y

FILE=A

三:注意事项

1、如何使用SYSDBA执行EXP/IMP?

有时候我们需要使用SYSDBA来执行EXP/IMP,如进行传输表空间的EXP/IMP,以及在9i下用SYS用户来执行EXP/IMP时,都需要使用SYSDBA才可。我们可以使用下面方式连入EXP/IMP:

exp

"'sys/sys as sysdba'" file=1.dmp tables=gototop.t

rows=n

2、QUERY参数后面跟的是where条件,值得注意的是,整个where子句需要使用""括起来,where子句的写法和

SELECT中相同,如果是UNIX平台所有"和'都需要使用\u26469屏蔽它们的特殊含义:

exp dacg/dacg@lmis file=1.dmp

log=1.log tables=cyx.t query="where c1=20 and c2=gototop"

如果是windows平台,则使用下面的格式: exp dacg/dacg@lmis file=c.dmp

log=c.log tables=t query="""where id=1 and name='gototop'"""

3.如何测试数据库是否可以连上

用tnsping lmis 来获得数据库 TestDB

能否连上。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值