国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

使用impdp復(fù)制Oracle的schema數(shù)據(jù)遷移

瀏覽:67日期:2023-11-28 17:38:16
使用impdp復(fù)制Oracle的schema數(shù)據(jù)遷移

測(cè)試環(huán)境如下:

源: windows 2003, oracle 10202

目標(biāo):windows 2000, oracle 10203

注:文中的schema和user是一個(gè)概念。

impdp 的數(shù)據(jù)源既可以是expdp 導(dǎo)出來(lái)的DMP文件,也可以是一數(shù)據(jù)庫(kù),通過(guò)network_link 參數(shù)來(lái)指定數(shù)據(jù)源,schemas 參數(shù)說(shuō)明要復(fù)制的用戶,remap_schemas 參數(shù)說(shuō)明源用戶與目標(biāo)用戶的匹配關(guān)系,remap_tablepace 來(lái)調(diào)整原 schemas 使用的表空間與目標(biāo)數(shù)據(jù)庫(kù)用戶要表空間的對(duì)應(yīng)關(guān)系。這樣,基本上可以把源schema的數(shù)據(jù)導(dǎo)入到目標(biāo)數(shù)據(jù)庫(kù)。格式如下:

impdp user/password parfile=parfile.log

**********parfile.log 的內(nèi)容***************

network_link=目標(biāo)數(shù)據(jù)庫(kù)上的數(shù)據(jù)庫(kù)鏈。

schema=源數(shù)據(jù)庫(kù)上導(dǎo)出數(shù)據(jù)的用戶。

remap_schema=源用戶:目標(biāo)用戶。

remap_tablespace=源用戶使用的表空間:目標(biāo)用戶將使用的表空間(包括臨時(shí)表空間)。

**********parfile.log 的內(nèi)容***************

過(guò)程舉例:

在目標(biāo)數(shù)據(jù)庫(kù)上創(chuàng)建數(shù)據(jù)庫(kù)鏈,指向源數(shù)據(jù)庫(kù),數(shù)據(jù)庫(kù)鏈中連接的用戶必須具備EXP_FULL_DATABASE角色的權(quán)限。 例:

A、新建數(shù)據(jù)庫(kù)鏈里的用戶,授予create session 和使用users 空間的權(quán)限,

SQL> create user link identified by '1';

用戶已創(chuàng)建。

SQL> grant create session to link;

授權(quán)成功。

SQL> ALTER USER LINK QUOTA UNLIMITED ON USERS;

用戶已更改。

B、為該用戶創(chuàng)建一表,用于測(cè)試復(fù)制用戶過(guò)程。

SQL> CREATE TABLE LINK.DOC_TYPE AS SELECT * FROM INFO.DOC_TYPE;

表已創(chuàng)建。

SQL> SELECT TABLE_NAME FROM DBA_TABLES WHERE OWNER='LINK';

TABLE_NAME

------------------------------

DOC_TYPE

C、使用該用戶來(lái)創(chuàng)建數(shù)據(jù)庫(kù)鏈。

SQL> create public database link tolink connect to link identified by '1' using '37ZHS';

數(shù)據(jù)庫(kù)鏈接已創(chuàng)建。

D、使用該鏈來(lái)復(fù)制link用戶,報(bào) ORA-39149: cannot link privileged user to non-privileged user

錯(cuò)誤。

d:oracleproduct10.2.0db_1BIN>impdp network_link=tolink schemas=link remap_schema=link:link2

Import: Release 10.2.0.2.0 - Production on Wednesday, 07 March, 2007 16:51:37

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

Username: / as sysdba

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Production

With the Partitioning, OLAP and Data Mining options

ORA-31631: privileges are required

ORA-39149: cannot link privileged user to non-privileged user

F、授予 exp_ful_database 權(quán)限后,復(fù)制成功。

SQL> grant exp_full_database to link;

授權(quán)成功。

d:oracleproduct10.2.0db_1BIN>impdp network_link=tolink schemas=link remap_schema=link:link2

Import: Release 10.2.0.2.0 - Production on Wednesday, 07 March, 2007 16:54:30

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

Username: / as sysdba

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Production

With the Partitioning, OLAP and Data Mining options

FLASHBACK automatically enabled to preserve database integrity.

Starting 'SYS'.'SYS_IMPORT_SCHEMA_01': /******** AS SYSDBA network_link=tolink schemas=link remap

_schema=link:link2

Estimate in progress using BLOCKS method...

Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA

Total estimation using BLOCKS method: 64 KB

Processing object type SCHEMA_EXPORT/USER

Processing object type SCHEMA_EXPORT/SYSTEM_GRANT

Processing object type SCHEMA_EXPORT/ROLE_GRANT

Processing object type SCHEMA_EXPORT/DEFAULT_ROLE

Processing object type SCHEMA_EXPORT/TABLESPACE_QUOTA

Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA

Processing object type SCHEMA_EXPORT/TABLE/TABLE

. . imported 'LINK2'.'DOC_TYPE' 8 rows

Job 'SYS'.'SYS_IMPORT_SCHEMA_01' successfully completed at 16:54:52

又如,在兩數(shù)據(jù)庫(kù)間復(fù)制用戶:

A、源數(shù)據(jù)庫(kù)是上面例子中的LINK,

B、目標(biāo)數(shù)據(jù)庫(kù)是10203版本,要將源中的LINK復(fù)制到目標(biāo)中的LINK2中。

SYS@BTB>create public database link tolink connect to link identified by '1' using '37zhs';

數(shù)據(jù)庫(kù)鏈接已創(chuàng)建。

SYS@BTB>SELECT * FROM TAB@TOLINK;

TNAME TABTYPE CLUSTERID

------------------------------ ------- ----------

DOC_TYPE TABLE

F:oracleproduct10.2.0db_1BIN>impdp network_link=tolink schemas=link remap_schema=link:link2

Import: Release 10.2.0.3.0 - Production on 星期三, 07 3月, 2007 17:36:32

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

用戶名: / as sysdba

連接到: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production

With the Partitioning, OLAP and Data Mining options

自動(dòng)啟用 FLASHBACK 以保持?jǐn)?shù)據(jù)庫(kù)完整性。

啟動(dòng) 'SYS'.'SYS_IMPORT_SCHEMA_03': /******** AS SYSDBA network_link=tolink schemas=link remap_sch

ema=link:link2

正在使用 BLOCKS 方法進(jìn)行估計(jì)...

處理對(duì)象類型 SCHEMA_EXPORT/TABLE/TABLE_DATA

使用 BLOCKS 方法的總估計(jì): 64 KB

處理對(duì)象類型 SCHEMA_EXPORT/USER

處理對(duì)象類型 SCHEMA_EXPORT/SYSTEM_GRANT

處理對(duì)象類型 SCHEMA_EXPORT/ROLE_GRANT

處理對(duì)象類型 SCHEMA_EXPORT/DEFAULT_ROLE

處理對(duì)象類型 SCHEMA_EXPORT/TABLESPACE_QUOTA

處理對(duì)象類型 SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA

處理對(duì)象類型 SCHEMA_EXPORT/TABLE/TABLE

. . 導(dǎo)入了 'LINK2'.'DOC_TYPE' 8 行

作業(yè) 'SYS'.'SYS_IMPORT_SCHEMA_03' 已于 17:40:14 成功完成

F:oracleproduct10.2.0db_1BIN>

SYS@BTB>select * from all_users order by 3;

USERNAME USER_ID CREATED

------------------------------ ---------- -------------------

SYSTEM 5 2006-11-19 10:27:12

SYS 0 2006-11-19 10:27:12

OUTLN 11 2006-11-19 10:27:18

DIP 19 2006-11-19 10:34:16

TSMSYS 21 2006-11-19 10:44:48

DBSNMP 24 2006-11-19 10:48:58

WMSYS 25 2006-11-19 10:51:52

MGMT_VIEW 53 2006-11-19 11:41:09

SCOTT 54 2006-11-19 11:43:42

SCOTT2 62 2007-03-01 14:50:06

LINK2 63 2007-03-07 17:39:34

從LINK2的創(chuàng)建時(shí)間可以知道,該用戶是剛創(chuàng)建的。

從以上兩個(gè)例子中大家可以看出,不論是在兩數(shù)據(jù)庫(kù)間,還是在同一數(shù)據(jù)庫(kù)里復(fù)制SCHEMAS,都必須

使用network_link,才能說(shuō)明是在復(fù)制數(shù)據(jù)。

2.'remap_schema=源用戶:目標(biāo)用戶' 中的目標(biāo)用戶可以事先創(chuàng)建。

主站蜘蛛池模板: 施甸县| 和硕县| 辛集市| 金乡县| 高要市| 青铜峡市| 乡宁县| 尤溪县| 麻栗坡县| 青海省| 阜南县| 锡林浩特市| 新郑市| 平阴县| 石楼县| 新乡县| 财经| 吉首市| 两当县| 盘山县| 辽中县| 临朐县| 永修县| 金沙县| 东乡| 平泉县| 措美县| 桂东县| 开阳县| 吉安市| 新建县| 宝山区| 阳泉市| 乐昌市| 南平市| 红河县| 泾源县| 阜平县| 海南省| 东乡族自治县| 彭山县|