<span id="mktg5"></span>

<i id="mktg5"><meter id="mktg5"></meter></i>

        <label id="mktg5"><meter id="mktg5"></meter></label>
        最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
        問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
        當前位置: 首頁 - 科技 - 知識百科 - 正文

        EXPDP/IMPDP與EXP/IMP在不同用戶和表空間之間遷移數據的實現方法

        來源:懂視網 責編:小采 時間:2020-11-09 14:52:27
        文檔

        EXPDP/IMPDP與EXP/IMP在不同用戶和表空間之間遷移數據的實現方法

        EXPDP/IMPDP與EXP/IMP在不同用戶和表空間之間遷移數據的實現方法:1. EXPDP/IMPDP方式 SQL create user zlm identified by zlm; User created. SQL grant connect,resource to zlm; Grant succeeded. SQL create tablespace ts_zlm datafile /u01/app/oracle/ora
        推薦度:
        導讀EXPDP/IMPDP與EXP/IMP在不同用戶和表空間之間遷移數據的實現方法:1. EXPDP/IMPDP方式 SQL create user zlm identified by zlm; User created. SQL grant connect,resource to zlm; Grant succeeded. SQL create tablespace ts_zlm datafile /u01/app/oracle/ora

        1. EXPDP/IMPDP方式 SQL create user zlm identified by zlm; User created. SQL grant connect,resource to zlm; Grant succeeded. SQL create tablespace ts_zlm datafile /u01/app/oracle/oradata/ora10g/zlm01.dbf size 100M reuse; Tablespace created.

        1. EXPDP/IMPDP方式

        SQL> create user zlm identified by zlm;

        User created.

        SQL> grant connect,resource to zlm;

        Grant succeeded.

        SQL> create tablespace ts_zlm datafile '/u01/app/oracle/oradata/ora10g/zlm01.dbf' size 100M reuse;

        Tablespace created.

        SQL> alter user zlm default tablespace ts_zlm;

        User altered.

        SQL> select username,default_tablespace from dba_users where username='ZLM';

        USERNAME DEFAULT_TABLESPACE
        ------------------------------ ------------------------------
        ZLM TS_ZLM

        SQL> col name for a50
        SQL> select name,bytes/1024/1024 from v$datafile where name like '%users01.dbf';

        NAME BYTES/1024/1024
        -------------------------------------------------- ---------------
        /u01/app/oracle/oradata/ora10g/users01.dbf 5

        SQL> set lin 120 pages 120
        SQL> col username for a8
        SQL> col name for a45
        SQL> select a.username,a.default_tablespace,b.name from dba_users a,v$datafile b,v$tablespace c where a.default_tablespace=c.name and b.ts#=c.ts# and a.username='SCOTT';

        USERNAME DEFAULT_TABLESPACE NAME
        -------- ------------------------------ ---------------------------------------------
        SCOTT USERS /u01/app/oracle/oradata/ora10g/users01.dbf

        SQL> alter database datafile '/u01/app/oracle/oradata/ora10g/users01.dbf' resize 100M;

        Database altered.

        SQL> select name,bytes/1024/1024 from v$datafile where name like '%users01.dbf';

        NAME BYTES/1024/1024
        --------------------------------------------- ---------------
        /u01/app/oracle/oradata/ora10g/users01.dbf 100

        SQL> select owner,directory_name from dba_directories;

        OWNER DIRECTORY_NAME
        ------------------------------ ------------------------------
        SYS DATA_PUMP_DIR
        SYS SUBDIR
        SYS XMLDIR
        SYS MEDIA_DIR
        SYS LOG_FILE_DIR
        SYS DATA_FILE_DIR
        SYS WORK_DIR
        SYS ADMIN_DIR

        SQL> create directory zlm_pump as '/u01/expdp';

        Directory created.

        SQL> !mkdir /u01/expdp

        SQL> alter user scott identified by tiger account unlock;

        User altered.

        SQL> grant connect,resource to scott;

        Grant succeeded.

        SQL> grant read,write on directory zlm_pump to scott;

        Grant succeeded.

        SQL> conn scott/tiger
        Connected.
        SQL> create table zlm1 as select * from dba_objects;

        Table created.

        SQL> insert into zlm1 select * from dba_objects;

        50318 rows created.

        SQL> /

        50318 rows created.

        SQL> select count(*) from zlm1;

        COUNT(*)
        ----------
        150954

        SQL> select table_name from user_tables where tablespace_name='USERS';

        TABLE_NAME
        ------------------------------
        ZLM1
        SALGRADE
        BONUS
        EMP
        DEPT

        [oracle@ora10g ~]$ expdp scott/tiger parallel=2 directory=zlm_pump dumpfile=scott01.dmp,scott02.dmp tablespaces=users

        Export: Release 10.2.0.1.0 - Production on Sunday, 31 August, 2014 14:35:29

        Copyright (c) 2003, 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
        Starting "SCOTT"."SYS_EXPORT_TABLESPACE_01": scott/******** parallel=2 directory=zlm_pump dumpfile=scott01.dmp,scott02.dmp tablespaces=users
        Estimate in progress using BLOCKS method...--可以通過estimate=block(默認值)指定,還有一個是statistic
        Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
        Total estimation using BLOCKS method: 17.18 MB
        Processing object type TABLE_EXPORT/TABLE/TABLE
        . . exported "SCOTT"."ZLM1" 14.06 MB 150954 rows
        . . exported "SCOTT"."DEPT" 5.656 KB 4 rows
        . . exported "SCOTT"."EMP" 7.820 KB 14 rows
        . . exported "SCOTT"."SALGRADE" 5.585 KB 5 rows
        . . exported "SCOTT"."BONUS" 0 KB 0 rows
        Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX
        Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
        Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
        Processing object type TABLE_EXPORT/TABLE/COMMENT
        Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
        Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
        Master table "SCOTT"."SYS_EXPORT_TABLESPACE_01" successfully loaded/unloaded
        ******************************************************************************
        Dump file set for SCOTT.SYS_EXPORT_TABLESPACE_01 is:
        /u01/expdp/scott01.dmp
        /u01/expdp/scott02.dmp
        Job "SCOTT"."SYS_EXPORT_TABLESPACE_01" successfully completed at 14:36:10

        [oracle@ora10g ~]$ impdp zlm/zlm parallel=2 remap_schema=scott:zlm remap_tablespace=users:ts_zlm directory=zlm_pump dumpfile=scott01.dmp,scott02.dmp

        Import: Release 10.2.0.1.0 - Production on Sunday, 31 August, 2014 14:41:30

        Copyright (c) 2003, 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
        Master table "ZLM"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
        Starting "ZLM"."SYS_IMPORT_FULL_01": zlm/******** parallel=2 remap_schema=scott:zlm remap_tablespace=users:ts_zlm directory=zlm_pump dumpfile=scott01.dmp,scott02.dmp
        Processing object type TABLE_EXPORT/TABLE/TABLE
        Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
        . . imported "ZLM"."DEPT" 5.656 KB 4 rows
        . . imported "ZLM"."EMP" 7.820 KB 14 rows
        . . imported "ZLM"."SALGRADE" 5.585 KB 5 rows
        . . imported "ZLM"."BONUS" 0 KB 0 rows
        . . imported "ZLM"."ZLM1" 14.06 MB 150954 rows
        Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX
        Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
        Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
        Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
        Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
        Job "ZLM"."SYS_IMPORT_FULL_01" successfully completed at 14:41:43
        [oracle@ora10g ~]$ sqlplus /nolog

        SQL*Plus: Release 10.2.0.1.0 - Production on Sun Aug 31 14:43:12 2014

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

        SQL> conn zlm/zlm
        Connected.
        SQL> select table_name from user_tables where tablespace_name='TS_ZLM';

        TABLE_NAME
        ------------------------------
        ZLM1
        SALGRADE
        BONUS
        EMP
        DEPT

        SQL> select object_name from user_objects;

        OBJECT_NAME
        --------------------------------------------------------------------------------
        DEPT
        EMP
        BONUS
        SALGRADE
        ZLM1
        PK_DEPT
        PK_EMP

        SCHEMA SCOTT的表空間USERS中的全部對象已經被導入到SCHEMA ZLM的表空間,包括表和索引

        2. EXP/IMP方式

        SQL> conn / as sysdba
        Connected.
        SQL> drop user zlm cascade;

        User dropped.

        SQL> create user zlm identified by zlm;

        User created.

        SQL> grant connect,resource to zlm;

        Grant succeeded.

        SQL> alter user zlm default tablespace ts_zlm;

        User altered.

        SQL> conn zlm/zlm
        Connected.
        SQL> select * from cat;

        no rows selected

        SQL> !
        [oracle@ora10g ~]$ exp scott/tiger owner=scott file=/u01/scott01.dmp

        Export: Release 10.2.0.1.0 - Production on Sun Aug 31 15:42:00 2014

        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 US7ASCII character set and AL16UTF16 NCHAR character set
        server uses ZHS16GBK character set (possible charset conversion)
        . exporting pre-schema procedural objects and actions
        . exporting foreign function library names for user SCOTT
        . exporting PUBLIC type synonyms
        . exporting private type synonyms
        . exporting object type definitions for user SCOTT
        About to export SCOTT's objects ...
        . exporting database links
        . exporting sequence numbers
        . exporting cluster definitions
        . about to export SCOTT's tables via Conventional Path ...
        . . exporting table BONUS 0 rows exported
        EXP-00091: Exporting questionable statistics.
        . . exporting table DEPT 4 rows exported
        EXP-00091: Exporting questionable statistics.
        EXP-00091: Exporting questionable statistics.
        . . exporting table EMP 14 rows exported
        EXP-00091: Exporting questionable statistics.
        EXP-00091: Exporting questionable statistics.
        . . exporting table SALGRADE 5 rows exported
        EXP-00091: Exporting questionable statistics.
        . . exporting table ZLM1 150954 rows exported
        . exporting synonyms
        . exporting views
        . exporting stored procedures
        . exporting operators
        . exporting referential integrity constraints
        . exporting triggers
        . exporting indextypes
        . exporting bitmap, functional and extensible indexes
        . exporting posttables actions
        . exporting materialized views
        . exporting snapshot logs
        . exporting job queues
        . exporting refresh groups and children
        . exporting dimensions
        . exporting post-schema procedural objects and actions
        . exporting statistics
        Export terminated successfully with warnings.
        [oracle@ora10g ~]$ imp zlm/zlm fromuser=scott touser=zlm file=/u01/exp/scott01.dmp

        Import: Release 10.2.0.1.0 - Production on Sun Aug 31 15:43:01 2014

        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

        IMP-00002: failed to open /u01/exp/scott01.dmp for read --路徑指定錯了
        Import file: expdat.dmp > /u01/scott01.dmp

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

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

        import done in US7ASCII character set and AL16UTF16 NCHAR character set
        import server uses ZHS16GBK character set (possible charset conversion)
        . . importing table "BONUS" 0 rows imported
        . . importing table "DEPT" 4 rows imported
        . . importing table "EMP" 14 rows imported
        . . importing table "SALGRADE" 5 rows imported
        . . importing table "ZLM1" 150954 rows imported
        About to enable constraints...
        Import terminated successfully with warnings.
        [oracle@ora10g ~]$ exit
        SQL> col object_name for a15
        SQL> select object_name,object_type from user_objects;

        OBJECT_NAME OBJECT_TYPE
        --------------- -------------------
        BONUS TABLE
        DEPT TABLE
        PK_DEPT INDEX
        EMP TABLE
        PK_EMP INDEX
        SALGRADE TABLE
        ZLM1 TABLE

        SQL> select table_name,tablespace_name from user_tables;

        TABLE_NAME TABLESPACE_NAME
        ------------------------------ ------------------------------
        BONUS USERS
        DEPT USERS
        EMP USERS
        SALGRADE USERS
        ZLM1 USERS

        注意,用imp導入后的對象,都是存放在exp導出時的表空間的,如果要遷移到別的表空間,就要使用alter table move tablespace來實現,先通過下面的SQL拼接語句來獲得批量move的語句: SQL> select 'alter table '||table_name||' MOVE TABLESPACE ts_zlm;' from user_tables;

        'ALTERTABLE'||TABLE_NAME||'MOVETABLESPACETS_ZLM;'
        ------------------------------------------------------------------
        alter table BONUS MOVE TABLESPACE ts_zlm;
        alter table DEPT MOVE TABLESPACE ts_zlm;
        alter table EMP MOVE TABLESPACE ts_zlm;
        alter table SALGRADE MOVE TABLESPACE ts_zlm;
        alter table ZLM1 MOVE TABLESPACE ts_zlm;

        SQL> select 'ALTER INDEX ' ||index_name || ' REBUILD TABLESPACE ts_zlm;' from user_indexes;

        'ALTERINDEX'||INDEX_NAME||'REBUILDTABLESPACETS_ZLM;'
        ---------------------------------------------------------------------
        ALTER INDEX PK_EMP REBUILD TABLESPACE ts_zlm;
        ALTER INDEX PK_DEPT REBUILD TABLESPACE ts_zlm;

        SQL> select table_name,tablespace_name from user_tables;

        TABLE_NAME TABLESPACE_NAME
        ------------------------------ ------------------------------
        SALGRADE TS_ZLM
        EMP TS_ZLM
        ZLM1 TS_ZLM
        DEPT TS_ZLM
        BONUS TS_ZLM

        SQL> select index_name,tablespace_name from user_indexes;

        INDEX_NAME TABLESPACE_NAME
        ------------------------------ ------------------------------
        PK_EMP TS_ZLM
        PK_DEPT TS_ZLM

        可以看到,zlm用戶imp導入的數據庫對象已經全部遷移到TS_ZLM表空間去了

        總結:

        EXPDP/IPMDP只能在server上運行,其運行效率完全取決于磁盤I/O,而EXP/IMP不僅可以運行在server上,也可以運行在client上,所以除了磁盤I/O的制約因素,還有網絡方面的因素。

        EXPDP/IMPDP比EXP/IMP性能有很大的提高,其中影響最大的就是paralle,通常設置為CPU的個數,通過該參數可以并行導出,大大提高導出速度,而EXP/IMP是沒有這個功能的,最多也就只有一個DIRECT=Y,使導出不用經過SELECT到SGA的BUFFER中,提高的速度是有限的,注意他們之間的語法也有不小的區別,參數不可互相替代。

        EXPDP/IMPDP可以通過remap_schema和remap_tablespace直接實現不同用戶和表空間之間的數據遷移;而EXP/IMP則稍微麻煩一點,需要ALTER TABLE xxx MOVE TABLESPACE xxx/ALTER INDEX xxx REBUILD TABLESPACE xxx方式來實現。move相當于把表再重建一次,可以修改storage參數(如initial、pctfree、pctincrease等),還可以move到另外的表空間,如果不指定表空間,則在原來的表空間中move,因此做move操作時,目標表空間需要保證有這個表同樣大小的剩余空間,整個操作相當于exp/imp(從表空間A導出到表空間B),move完表后要重建索引。

        基于以上幾種原因,現在做數據邏輯遷移都是用EXPDP/IMPDP而很少再使用EXP/IMP了。

        聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

        文檔

        EXPDP/IMPDP與EXP/IMP在不同用戶和表空間之間遷移數據的實現方法

        EXPDP/IMPDP與EXP/IMP在不同用戶和表空間之間遷移數據的實現方法:1. EXPDP/IMPDP方式 SQL create user zlm identified by zlm; User created. SQL grant connect,resource to zlm; Grant succeeded. SQL create tablespace ts_zlm datafile /u01/app/oracle/ora
        推薦度:
        標簽: 空間 用戶 數據
        • 熱門焦點

        最新推薦

        猜你喜歡

        熱門推薦

        專題
        Top
        主站蜘蛛池模板: 亚洲国产精品一区二区久久hs| 亚洲国产天堂久久综合| 亚洲VA中文字幕无码一二三区 | 人妻在线日韩免费视频| 亚洲综合国产一区二区三区| 一级特黄a免费大片| 亚洲中文字幕无码专区| 成人免费ā片在线观看| 久久久久久亚洲精品| 日韩免费电影网址| 亚洲一区二区在线视频| 91久久成人免费| 亚洲1234区乱码| 午夜视频免费成人| 免费精品国自产拍在线播放| 亚洲人成电影网站国产精品| a在线观看免费视频| 久久亚洲春色中文字幕久久久 | 亚洲综合一区二区精品导航| 131美女爱做免费毛片| 精品亚洲成在人线AV无码| 免费无码一区二区三区蜜桃大| 美女免费精品高清毛片在线视| 亚洲一区二区三区无码中文字幕| 久久国产免费观看精品| 久久精品亚洲中文字幕无码麻豆| 国产成人无码免费看视频软件 | 一级毛片a女人刺激视频免费| 亚洲中文字幕无码一久久区| 日韩精品无码一区二区三区免费| 亚洲精品91在线| 国产精品免费看久久久无码| 精品一区二区三区免费视频| 亚洲韩国在线一卡二卡| 成人免费无码精品国产电影| 精品免费久久久久国产一区| 亚洲人成电影在线观看青青| 亚洲女同成人AⅤ人片在线观看| 免费高清国产视频| 亚洲精品自偷自拍无码| 亚洲AV永久无码精品一百度影院|