ORACLE 导出(exp) & 导入(imp)

导出(exp) & 导入(imp) 
    利用Export可将数据从数据库中提取出来,就是将select的结果存到一个FS二进制文件上
    利用Import则可将提取出来的数据送回到Oracle数据库中去。 
    要读写数据文件内数据,所以数据库必须open
    不能备份活跃频繁数据 
    exp满足select的所有特性 比如权限或读一致性
    imp满足insert的所有特性 比如主键或空间不足

Oracle支持三种方式基本类型的输出: 
1.表方式(T方式),将指定表的数据导出。 
2.用户方式(U方式),将指定用户的所有对象及数据导出。 
3.全库方式(Full方式),数据库中的所有对象导出。

数据导入(Import)的过程是数据导出(Export)的逆过程,
分别将数据文件导入数据库和将数据库数据导出到数据文件。

交互模式导出exp表

[[email protected] ~]$ exp

Export: Release 10.2.0.1.0 - Production on Mon Apr 4 16:58:41 2011

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Username: scott
Password:

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
Enter array fetch buffer size: 4096 >

Export file: expdat.dmp > scott_tab_emp.dmp

(2)U(sers), or (3)T(ables): (2)U > T

Export table data (yes/no): yes >

Compress extents (yes/no): yes >

Export done in AL32UTF8 character set and AL16UTF16 NCHAR character set

About to export specified tables via Conventional Path ...

Table(T) or Partition(T:P) to be exported: (RETURN to quit) > emp

. . exporting table                            EMP         14 rows exported

Table(T) or Partition(T:P) to be exported: (RETURN to quit) > dept

. . exporting table                           DEPT          4 rows exported

Table(T) or Partition(T:P) to be exported: (RETURN to quit) >  回车退出

Export terminated successfully with warnings.
[[email protected] ~]$

查看备份文件
[[email protected] ~]$ ll -thr scott_tab_emp.dmp 
-rw-r--r-- 1 oracle oinstall 24K 04-04 17:00 scott_tab_emp.dmp
[[email protected] ~]$ file scott_tab_emp.dmp 
scott_tab_emp.dmp: DBase 3 data file (1380929624 records)
[[email protected] ~]$ strings scott_tab_emp.dmp

导出的文件是二进制文件 如果要经历FTP传输 一定要使用binary传输模式传 如果使用ASCII模式传输会损坏文件
    windows cmd里的ftp 默认是ascii传输模式

linux   lftp ftp等工具默认基本都是binary模式
    修改方法

C:\>ftp
    ftp> status
    Not connected.
    Type: ascii; Verbose: On ; Bell: Off ; Prompting: On ; Globbing: On
    Debugging: Off ; Hash mark printing: Off .
    ftp>
    ftp> help
    Commands may be abbreviated.

!               delete
    ?               debug
    append          dir
    ascii           disconnect
    bell            get
    binary          glob
    bye             hash
    cd              help
    close           lcd
    ftp>

[[email protected] ~]$ ftp 127.0.0.1
    Connected to 127.0.0.1 (127.0.0.1).
    220 (vsFTPd 2.0.5)
    Name (127.0.0.1:oracle): 
    331 Please specify the password.
    Password:
    230 Login successful.
    Remote system type is UNIX.
    Using binary mode to transfer files.
    ftp> status
    Connected to 127.0.0.1.
    No proxy connection.
    Mode: stream; Type: binary; Form: non-print; Structure: file
    Verbose: on; Bell: off; Prompting: on; Globbing: on
    Store unique: off; Receive unique: off
    Case: off; CR stripping: on
    Ntrans: off
    Nmap: off
    Hash mark printing: off; Use of PORT cmds: on
    Tick counter printing: off
    ftp>

[[email protected] ~]$ lftp [email protected]
    口令: 
    lftp [email protected]:~> help get
    用法: get [OPTS] <rfile> [-o <lfile>]
    Retrieve remote file <rfile> and store it to local file <lfile>.
    .........
     -a  use ascii mode (binary is the default)
    .........
    lftp [email protected]:~> help put
    用法: put [OPTS] <lfile> [-o <rfile>]
    Upload <lfile> with remote name <rfile>.
    .........
     -a  use ascii mode (binary is the default)
    .........
    lftp [email protected]:~>

备份出来的是什么内容  只是对象的元数据 + 用户数据
[[email protected] exp_dir]$ strings cmd_scott_tab.dmp | grep -i ‘CREATE‘ --color
CREATE TABLE "EMP" ("EMPNO" NUMBER(4, 0), "ENAME" VARCHAR2(10), ....
CREATE UNIQUE INDEX "PK_EMP" ON "EMP" ("EMPNO" )  ....
CREATE TABLE "DEPT" ("DEPTNO" NUMBER(2, 0), "DNAME" VARCHAR2(14), ....
CREATE UNIQUE INDEX "PK_DEPT" ON "DEPT" ("DEPTNO" )  ....

命令模式备份表

[[email protected] exp_dir]$ exp USERID=SCOTT/seker TABLES=EMP,DEPT FILE=cmd_scott_tab.dmp

Export: Release 10.2.0.1.0 - Production on Mon Apr 4 17:16:22 2011

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
Export done in AL32UTF8 character set and AL16UTF16 NCHAR character set

About to export specified tables via Conventional Path ...
. . exporting table                            EMP         14 rows exported
. . exporting table                           DEPT          4 rows exported
Export terminated successfully without warnings.
[[email protected] exp_dir]$

交互模式备份schema
    
[[email protected] exp_dir]$ exp

Export: Release 10.2.0.1.0 - Production on Mon Apr 4 17:37:00 2011

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Username: scott
Password:

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
Enter array fetch buffer size: 4096 >

Export file: expdat.dmp > schema_scott.dmp

(2)U(sers), or (3)T(ables): (2)U > U

Export grants (yes/no): yes >

Export table data (yes/no): yes >

Compress extents (yes/no): yes >

Export done in AL32UTF8 character set and AL16UTF16 NCHAR character set
...............
Export terminated successfully without warnings.
[[email protected] exp_dir]$

命令模式备份schema
[[email protected] exp_dir]$ exp userid=scott/seker file=schema.scott.dmp

.............
Export terminated successfully without warnings.
[[email protected] exp_dir]$

只导出部分数据

[[email protected] exp_dir]$ exp userid=scott/seker tables=emp query=\‘where deptno=10\‘ statistics=none file=./emp_deptno_10.dmp log=./emp_deptno_10.log
表上有统计信息的时候会报EXP-0091错误,添加statistics=none即可
Export: Release 10.2.0.1.0 - Production on Mon Apr 4 17:59:29 2011

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
Export done in AL32UTF8 character set and AL16UTF16 NCHAR character set

About to export specified tables via Conventional Path ...
. . exporting table                            EMP
.
                                                            3 rows exported
Export terminated successfully without warnings.
[[email protected] exp_dir]$

只导出表结构
    导出时一定要加COMPRESS=n的选项 否则导入表是原始表的高水位 且没数据
    一个表大小是5M 
    COMPRESS=n 时得到元数据: STORAGE(INITIAL 65536)
    COMPRESS=y(默认) 时得到元数据:STORAGE(INITIAL 5242880) 这样创建的表很大 又没数据
[[email protected] ~]$ exp scott/seker tables=ob rows=n file=./ob.dmp

[[email protected] ~]$ exp scott/seker tables=ob rows=n COMPRESS=n file=./ob2.dmp

SQL> select segment_name,sum(bytes)/1024/1024 from user_extents where segment_name=‘OB‘ group by segment_name;

SEGMENT_NAME          SUM(BYTES)/1024/1024
------------------------- --------------------
OB                         5

SQL> drop table OB PURGE;

Table dropped.

SQL> !
[[email protected] ~]$ ls
Desktop  ob2.dmp  ob.dmp
[[email protected] ~]$ imp userid=scott/seker file=ob.dmp 
[[email protected] ~]$ exit
SQL> select segment_name,sum(bytes)/1024/1024 from user_extents where segment_name=‘OB‘ group by segment_name;

SEGMENT_NAME          SUM(BYTES)/1024/1024
------------------------- --------------------
OB                         5

SQL> !
[[email protected] ~]$ exit
exit

SQL> drop table ob purge;

Table dropped.

SQL> !
[[email protected] ~]$ imp userid=scott/seker file=ob2.dmp

SQL> select segment_name,sum(bytes)/1024/1024 from user_extents where segment_name=‘OB‘ group by segment_name;

SEGMENT_NAME          SUM(BYTES)/1024/1024
------------------------- --------------------
OB                     .0625

SQL>

使用参数文件

[[email protected] exp_dir]$ cat exp.txt 
userid=scott/seker
tables=emp
query=‘where deptno=10‘
statistics=none
file=./emp_deptno_10.dmp
buffer=100000
feedback=2
log=./emp_deptno_10.log
[[email protected] exp_dir]$ exp PARFILE=exp.txt

Export: Release 10.2.0.1.0 - Production on Mon Apr 4 17:59:52 2011

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
Export done in AL32UTF8 character set and AL16UTF16 NCHAR character set

About to export specified tables via Conventional Path ...
. . exporting table                            EMP
.
                                                            3 rows exported
Export terminated successfully without warnings.
[[email protected] exp_dir]$

当query中带有单引号时 用两个引号代替
[[email protected] exp_dir]$ cat exp.txt 
userid=scott/seker
tables=emp
query=‘where deptno=10 and ename=‘‘KING‘‘‘
statistics=none
file=./emp_deptno_10.dmp
buffer=100000
feedback=2
log=./emp_deptno_10.log
[[email protected] exp_dir]$

闪回导出(导出历史上某一时间点的数据状态,依赖undo老镜像):
--/home/oracle/exp.txt--
userid=system/oracle
tables=scott.emp
file=/home/oracle/expdept.dmp 
flashback_time="to_timestamp(‘2011-03-28 15:25:06‘,‘yyyy-mm-dd hh24:mi:ss‘)"
buffer=100000 
feedback=5000 
log=/home/oracle/expdept.log

备份的常用参数
    FEEDBACK             display progress every x rows (0)
    FILESIZE             maximum size of each dump file
    INDEXES             export indexes (Y)
    TRIGGERS              export triggers (Y)
    LOG                 log file of screen output

导入imp

指定表导入
[[email protected] exp_dir]$ imp userid=scott/seker file=schema.scott.dmp tables=t1 ;

Import: Release 10.2.0.1.0 - Production on Mon Apr 4 18:36:26 2011

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

Export file created by EXPORT:V10.02.01 via conventional path
import done in AL32UTF8 character set and AL16UTF16 NCHAR character set
. importing SCOTT‘s objects into SCOTT
. importing SCOTT‘s objects into SCOTT
. . importing table                           "T1"      24672 rows imported
Import terminated successfully without warnings.
[[email protected] exp_dir]$

导入带有外键约束的表 要连同主键表一起带入 否则建立外键报错 带有trigger的级联表也要这样
[[email protected] exp_dir]$ imp userid=scott/seker file=schema.scott.dmp tables=emp ;

Import: Release 10.2.0.1.0 - Production on Mon Apr 4 18:36:59 2011

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

Export file created by EXPORT:V10.02.01 via conventional path
import done in AL32UTF8 character set and AL16UTF16 NCHAR character set
. importing SCOTT‘s objects into SCOTT
. importing SCOTT‘s objects into SCOTT
. . importing table                          "EMP"         14 rows imported
IMP-00017: following statement failed with ORACLE error 942:
 "ALTER TABLE "EMP" ADD CONSTRAINT "FK_DEPTNO" FOREIGN KEY ("DEPTNO") REFEREN"
 "CES "DEPT" ("DEPTNO") ENABLE NOVALIDATE"
IMP-00003: ORACLE error 942 encountered
ORA-00942: table or view does not exist
About to enable constraints...
IMP-00017: following statement failed with ORACLE error 2430:
 "ALTER TABLE "EMP" ENABLE CONSTRAINT "FK_DEPTNO""
Import terminated successfully with warnings.
[[email protected] exp_dir]$

SQL> drop table emp purge;

Table dropped.

SQL>

[[email protected] exp_dir]$ imp userid=scott/seker file=schema.scott.dmp tables=emp,dept ;

Import: Release 10.2.0.1.0 - Production on Mon Apr 4 18:38:09 2011

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

Export file created by EXPORT:V10.02.01 via conventional path
import done in AL32UTF8 character set and AL16UTF16 NCHAR character set
. importing SCOTT‘s objects into SCOTT
. importing SCOTT‘s objects into SCOTT
. . importing table                         "DEPT"          4 rows imported
. . importing table                          "EMP"         14 rows imported
About to enable constraints...
Import terminated successfully without warnings.
[[email protected] exp_dir]$

导入到其他用户
    这样导入到的是system模式中去了
[[email protected] exp_dir]$ imp userid=system/oracle file=schema.scott.dmp tables=emp,dept ;

Import: Release 10.2.0.1.0 - Production on Mon Apr 4 18:41:30 2011

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

Export file created by EXPORT:V10.02.01 via conventional path

Warning: the objects were exported by SCOTT, not by you

import done in AL32UTF8 character set and AL16UTF16 NCHAR character set
. importing SCOTT‘s objects into SYSTEM
. importing SCOTT‘s objects into SYSTEM
. . importing table                         "DEPT"          4 rows imported
. . importing table                          "EMP"         14 rows imported
About to enable constraints...
Import terminated successfully without warnings.
[[email protected] exp_dir]$

使用touser参数 导入到指定用户  但userid的用户必须有权限 覆盖touser的权限的人才可以这样做
[[email protected] exp_dir]$ imp userid=system/oracle touser=scott file=schema.scott.dmp tables=emp,dept ;

Import: Release 10.2.0.1.0 - Production on Mon Apr 4 18:42:01 2011

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

Export file created by EXPORT:V10.02.01 via conventional path

Warning: the objects were exported by SCOTT, not by you

import done in AL32UTF8 character set and AL16UTF16 NCHAR character set
. importing SCOTT‘s objects into SCOTT
. . importing table                         "DEPT"          4 rows imported
. . importing table                          "EMP"         14 rows imported
About to enable constraints...
Import terminated successfully without warnings.
[[email protected] exp_dir]$

导入时追加数据
    表不能有主键
    正常导入时先建表 表存在就报错
    加ignore=y选项 就是忽略表存在 追加数据

导入到其他用户
SQL> create tablespace ts99 datafile ‘/u01/oracle/oradata/ora10g/ts99.dbf‘ size 20M;

Tablespace created.

SQL> create user u99 default tablespace ts99 identified by u99;

User created.

SQL> grant connect,resource to u99;

Grant succeeded.

SQL>

SQL> select owner,SEGMENT_NAME,TABLESPACE_NAME from  dba_extents where SEGMENT_NAME in (‘EMP‘,‘DEPT‘);

no rows selected

SQL>

[[email protected] exp_dir]$ imp userid=system/oracle touser=u99 file=schema.scott.dmp tables=emp,dept ;
导入成功 但存储位置却不是 ts99 这个u99的默认表空间 没达到我们的目的

SQL> select owner,SEGMENT_NAME,TABLESPACE_NAME from  dba_extents where SEGMENT_NAME in (‘EMP‘,‘DEPT‘);

OWNER                   SEGMENT_NAME         TABLESPACE_NAME
------------------------------ ------------------------- ---------------
U99                   DEPT             USERS
U99                   EMP             USERS

SQL>

原因是U99用户具备所有表空间不受限的权限 剔除这个权限 只给他默认表空间的权限
删除刚导入的表 重新导入
SQL> revoke UNLIMITED TABLESPACE from u99;

Revoke succeeded.

SQL>

SQL> alter user u99 quota unlimited on ts99;

User altered.

SQL>

[[email protected] exp_dir]$ imp userid=system/oracle touser=u99 file=schema.scott.dmp tables=emp,dept ;

SQL> select owner,SEGMENT_NAME,TABLESPACE_NAME from  dba_extents where SEGMENT_NAME in (‘EMP‘,‘DEPT‘);

OWNER                   SEGMENT_NAME         TABLESPACE_NAME
------------------------------ ------------------------- ---------------
U99                   DEPT             TS99
U99                   EMP             TS99

SQL> 达到目的

导入时追加数据
    表不能有主键
    正常导入时先建表 表存在就报错
    加ignore=y选项 就是忽略表存在 追加数据

导入的常用参数
    SHOW     just list file contents (N)
    COMMIT    commit array insert (N)
    BUFFER   size of data buffer
    很重要的两个参数 大表我们必须限制使用批量提交 以免回滚段小等问题
    commit=y        --降低导入的时候对回滚的压力。
                n -- 每张表数据导入完成后提交;
                y -- buffer满了以后就提交,一定要增大buffer的尺寸。

FULL         import entire file (N)
    indexfile=a.dmp
    
    indexes=N

备份表空间模式
    只是备份表空间中的存储对象 并不备份表空间自身的结构

[[email protected] exp_dir]$ exp userid=system/oracle tablespaces=ts99 file=./tbs_ts99.dmp log=./tbs_ts99.log

SQL> drop tablespace ts99 including contents and datafiles;

Tablespace dropped.

SQL>

[[email protected] exp_dir]$ imp userid=system/oracle file=./tbs_ts99.dmp full=y
.........
IMP-00003: ORACLE error 959 encountered
ORA-00959: tablespace ‘TS99‘ does not exist
IMP-00017: following statement failed with ORACLE error 959:
.........

SQL> create tablespace ts99 datafile ‘/u01/oracle/oradata/ora10g/ts99.dbf‘ size 20M;

Tablespace created.

SQL>

[[email protected] exp_dir]$ imp userid=system/oracle file=./tbs_ts99.dmp full=y

Import: Release 10.2.0.1.0 - Production on Tue Apr 5 03:18:47 2011

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

Export file created by EXPORT:V10.02.01 via conventional path
import done in AL32UTF8 character set and AL16UTF16 NCHAR character set
. importing SYSTEM‘s objects into SYSTEM
. importing U99‘s objects into U99
. . importing table                         "DEPT"          4 rows imported
. . importing table                          "EMP"         14 rows imported
About to enable constraints...
Import terminated successfully without warnings.
[[email protected] exp_dir]$

全库模式:
exp parfile=c:\exp.txt
----------------------
userid=system/oracle
full=y                                
filesize=50m                            定义文件大小,切割备份,为将来传输方便。
file=(c:\exp_full_1.dmp,c:\exp_full_2.dmp)    定义各种文件的名字,如果名字不够的话,导出进程会挂起要文件名字。
buffer=10000000
feedback=10000
log=c:\exp_full.log

imp parfile=c:\imp.txt
-----------------------
userid=system/oracle
full=y
filesize=50m
file=(c:\exp_full_1.dmp,c:\exp_full_2.dmp)
buffer=10000000
feedback=10000
log=c:\imp_full.log

表空间传输
从一个数据库中将一个表空间迁移至另一个数据库
    1.将本地表空间设置为只读
    2.导出表空间元数据,将导出文件和表空间包含的数据文件拿到远程
    3.远程库要手动建立和本地同样的用户
    4.导入表空间元数据,并指定原来的datafile
    5.本地和远程表空间都恢复读写 正常使用
    
1.将本地表空间设置为只读
SQL> alter tablespace ts99 read only;

Tablespace altered.

SQL>

2.导出表空间元数据,将导出文件和表空间包含的数据文件拿到远程
[[email protected] exp_dir]$ exp userid=\‘‘sys/oracle as sysdba‘\‘ tablespaces=ts99 transport_tablespace=y file=./trs_tbs_ts99.dmp

Export: Release 10.2.0.1.0 - Production on Tue Apr 5 03:27:01 2011

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
Export done in AL32UTF8 character set and AL16UTF16 NCHAR character set
Note: table data (rows) will not be exported
About to export transportable tablespace metadata...
For tablespace TS99 ...
. exporting cluster definitions
. exporting table definitions
. . exporting table                           DEPT
. . exporting table                            EMP
. exporting referential integrity constraints
. exporting triggers
. end transportable tablespace metadata export
Export terminated successfully without warnings.
[[email protected] exp_dir]$

SQL> ! cp /u01/oracle/oradata/ora10g/ts99.dbf /u01/oracle/oradata/orcl/

SQL>

3.远程库要手动建立和本地同样的用户
SQL> select file_name,file_id,tablespace_name from dba_data_files;

FILE_NAME                     FILE_ID TABLESPACE_NAME
--------------------------------------------- ---------- ---------------
/u01/oracle/oradata/orcl/users01.dbf               4 USERS
/u01/oracle/oradata/orcl/sysaux01.dbf               3 SYSAUX
/u01/oracle/oradata/orcl/undotbs01.dbf               2 UNDOTBS1
/u01/oracle/oradata/orcl/system01.dbf               1 SYSTEM

SQL> create user u99 identified by u99;

User created.

SQL> grant connect,resource to u99;

Grant succeeded.

SQL>

4.导入表空间元数据,并指定原来的datafile
[[email protected] exp_dir]$ export ORACLE_SID=newdb
[[email protected] exp_dir]$ imp userid=\‘‘sys/oracle as sysdba‘\‘ file=./trs_tbs_ts99.dmp tablespaces=ts99 transport_tablespace=y datafiles=\‘‘/u01/oracle/oradata/orcl/ts99.dbf‘\‘

Import: Release 10.2.0.1.0 - Production on Tue Apr 5 03:36:10 2011

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

Export file created by EXPORT:V10.02.01 via conventional path
About to import transportable tablespace(s) metadata...
import done in AL32UTF8 character set and AL16UTF16 NCHAR character set
. importing SYS‘s objects into SYS
. importing SYS‘s objects into SYS
. importing U99‘s objects into U99
. . importing table                         "DEPT"
. . importing table                          "EMP"
. importing SYS‘s objects into SYS
Import terminated successfully without warnings.
[[email protected] exp_dir]$

SQL> select file_name,file_id,tablespace_NAME FROM DBA_DATA_FILES;

FILE_NAME                     FILE_ID TABLESPACE_NAME
--------------------------------------------- ---------- ---------------
/u01/oracle/oradata/newdb/users01.dbf               4 USERS
/u01/oracle/oradata/newdb/sysaux01.dbf               3 SYSAUX
/u01/oracle/oradata/newdb/undotbs01.dbf            2 UNDOTBS1
/u01/oracle/oradata/newdb/system01.dbf               1 SYSTEM
/u01/oracle/oradata/orcl/ts99.dbf               5 TS99

SQL>

5.本地和远程表空间都恢复读写 正常使用
SQL> alter tablespace ts99 read write;

Tablespace altered.

SQL> conn u99/u99
Connected.
SQL> select * from tab;

TNAME                   TABTYPE    CLUSTERID
------------------------------ ------- ----------
DEPT                   TABLE
EMP                   TABLE

SQL>

时间: 2024-11-06 03:03:52

ORACLE 导出(exp) & 导入(imp)的相关文章

oracle的exp和imp命令的使用【转载】

oracle的exp和imp命令的使用 我们通常要对ORACLE的数据进行导入,导出,在没有expdb,impdb以前(10G以前),我们都是使用exp 导出,imp命令来实现导入. 打开CMD窗口,实现IMP,EXP主要是SQLPLUS.EXE调用IMP.EXE,EXP.EXE来完成的. 下面是几个常用的关于exp,imp命令的一些举例 举例导出数据库服务abc,用户user,密码psd下的table1,table2,table3表到d:\data目录下,导出文件名为test.dmp,语句为:

Oracle导出、导入数据库数据过程

Oracle导出.导入数据库数据过程 请查看附件:导出.导入数据库数据过程

Oracle数据库导入导出exp(expdp) imp(impdp)

Oracle数据库的导入导出 首先,又尴尬了一次. 其实oracle导入和导出命令是有两种的 即: exp(expdp) imp(impdp) 先给自己普及一下常识: 在平常备库和数据库迁移的时候,当遇到大的数据库的时候在用exp的时候往往是需要好几个小时,耗费大量时间.oracle10g以后可以用expdp来导出数据库花费的时间要远小于exp花费的时间,而且文件也要小很多. 1.使用expdp要先在数据库中创建directory,并给相应的用户read,write权限. SQL>create

oracle使用exp与imp在本地导入导出数据

导出: exp user/password owner=user file=你要输出的目录以及文件名,后缀为dmpexp IOTMON/iotmon owner=QSMES file=/home/oracle/iotmon.dmp导入:imp user/password file=文件所在的地址 (必须加full=y)imp qsmes/qsmes file=C:/files/qsmes.dmp full=y

oracle的emp导入imp导出命令

oracle导入导出命令详解(附数据库每天定时备份脚本) 一. 导出工具 exp 1. 它是操作系统下一个可执行的文件 存放目录/ORACLE_HOME/bin exp导出工具将数据库中数据备份压缩成一个二进制系统文件.可以在不同OS间迁移 它有三种模式: a.  用户模式: 导出用户所有对象以及对象中的数据: b.  表模式: 导出用户所有表或者指定的表: c.  整个数据库: 导出数据库中所有对象. 2. 导出工具exp交互式命令行方式的使用的例子 $exp test/[email prot

oracle 之 EXP、IMP 使用简介

注:DOS命令行中执行exp.imp 导出导入ORACLE数据,ORACLE操作者具有相应的权限! 1.1.导出整库或当前用户:关键字:full语法:exp 用户/密码@数据库实例名 file=导出文件之后存放的路径\文件名.dmp full=y注释:full=y 表示全库导出:full=n 表示将当前用户导出. full 总共有2个可选项yes(y)/no(n),默认full=no ,compress=y 是否对导出文件进行压缩.实例: 全库导出(需要用到sys或system 用户),并压缩成

Oracle 导出、导入某用户所有数据(包括表、视图、存储过程...)

前提:在CMD 命令下 导出命令:exp 用户名/密码@数据库 owner=用户名 file=文件存储路径(如:F:\abcd.dmp) 测试截图:exp ZM/[email protected] owner=ZM file=F\abcd.dmp 导入命令:imp 用户名/密码@数据库 fromuser=用户名 touser=用户名 file=d:\cu.dmp ignore=y imp:命令类型 cu/[email protected]:导入的数据库登陆(用户名/密码@数据库) fromuse

Oracle数据库exp和imp方式导数据

这里导入导出路径都在D盘下,默认文件名为:example.dmpexp方式导出数据相关参数项如下: 关键字  说明  默认USERID                     用户名/口令FULL                         导出整个文件  (N)BUFFER                    数据缓冲区的大小OWNER                     导出指定的所有者用户名列表FILE                           输出文件 (EXPDAT

oracle的exp、imp命令

1.EXP 1 a>完全模式 full=y 2 3 EXP USER/[email protected] (AS ROLE) BUFFER=64000 FILE=C:\FULL.DMP FULL=Y 4 5 b>用户模式 owner=user 6 7 EXP USER/[email protected] BUFFER=64000 FILE=C:\USER.DMP OWNER=USER 8 9 c>表模式 tables=tab_* 10 11 EXP USER/[email protect