Oracle数据备份与恢复——exp/imp

1 基本命令
1.1 获取帮助
C:\>exp help=y
C:\>imp help=y
 
1.2 三种工作方式
(1)交互式方式
C:\>exp        //  然后按提示输入所需要的参数
(2)命令行方式
C:\>exp user/pwd@dbname file=C:\test.dmp full=y    //  命令行中输入所需的参数
(3)参数文件方式
C:\>exp parfile=username.par    //  在参数文件中输入所需的参数
参数文件 username.par 内容 userid=username/userpassword buffer=8192000 compress=n grants=y file=C:\test.dmp full=y
1.3 三种模式 
(1)表方式,将指定表的数据导出/导入。
导出:
导出一张或几张表:
C:\>exp user/pwd file=fullpath\xxx.dmp log=fullpath\xxx.log tables=table1,table2
导出某张表的部分数据
C:\>exp user/pwd file=fullpath\xxx.dmp log=fullpath\xxx.log tables=table1 query=\" where col1=xxx and col2<xxx\"
导入:
导入一张或几张表
C:\>imp  user/pwd file=fullpath\xxx.dmp  log=fullpath\xxx.log tables=table1,table2 fromuser=dbuser touser=dbuser2 commit=y ignore=y
(2)用户方式,将指定用户的所有对象及数据导出/导入。
导出:
C:\>exp user/pwd file=fullpath\xxx.dmp log=fullpath\xxx.log owner=(xx,yy)
只导出数据对象,不导出数据  (rows=n )
C:\>exp user/pwd file=fullpath\xxx.dmp log=fullpath\xxx.log owner=user rows=n
导入:
C:\>imp user/pwd file=fullpath\xxx.dmp log=fullpath\xxx.log fromuser=dbuser touser=dbuser2 commit=y ignore=y
(3)全库方式,将数据库中的所有对象导出/导入导出:
C:\>exp user/pwd file=fullpath\xxx.dmp log=fullpath\xxx.log full=ycommit=y ignore=y
导入:
C:\>imp user/pwd file=fullpath\xxx.dmp log=fullpath\xxx.log fromuser=dbuser touser=dbuser2
2 高级选项
2.1分割成多个文件
以多个固定大小文件方式导出:这种做法通常用在表数据量较大,单个 dump文件可能会超出文件系统的限制的情况
C:\>exp user/pwd file=1.dmp,2.dmp,3.dmp,… filesize=1000m log=xxx.log full=y
以多个固定大小文件方式导入
C:\> imp  user/pwd file=1.dmp,2.dmp,3.dmp,… filesize=1000m tables=xxx fromuser=dbuser touser=dbuser2 commit=y ignore=y
2.2 增量导出/导入
// oracle 9i  以后 exp  不再支持  inctype
必须为  SYS  或  SYSTEM  才可执行增量导出导入
增量导出:   包括三个类型:
(1)“完全”增量导出(Complete)  //  备份整个数据库
C:\>exp user/pwd file=fullpath\xxx.dmp log=xxx.log inctype=complete
(2)“增量型”增量导出      导出上一次备份后改变的数据。
C:\>exp user/pwd file=fullpath\xxx.dmp log=xxx.log inctype=incremental
(3)  “累计型”增量导出(Cumulative)只导出自上次“完全”导出之后数据库中变化了的信息。
C:\>exp user/pwd file=fullpath\xxx.dmp log=xxx.log inctype=cumulative
增量导入:
C:\>imp usr/pwd FULL=y inctype=system/restore/inct ype
其中:
SYSTEM:   导入系统对象
RESTORE:  导入所有用户对象
 
2.3 以SYSDBA进行导出/导入
2.3.1 用于 Oracle 技术支持
2.3.2 用于表空间传输
例:
C:\>imp \'usr/pwd@instance as sysdba\' tablespaces=xx transport_tablespace=y file=xxx.dmp datafiles=xxx.dbf
C:\>imp file=expdat.dmp userid=\"sys/password as sysdba\" transport_tablespace=y datafiles=(c:\tempapp_data,c:\tempapp_index)

Leave a Reply


提醒: 评论者允许使用'@user空格'的方式将自己的评论通知另外评论者。例如, ABC是本文的评论者之一,则使用'@ABC '(不包括单引号)将会自动将您的评论发送给ABC。请务必注意user必须和评论者名相匹配(大小写一致)。