Oracle 10g的EXPDP与IMPDP的导出与导入测试
通过DB_LINK的复制功能,利用expdp,impdp进行数据的远程备份及恢复。进行测试前,将服务器B上scott用户的dept,emp进行删除,本测
实验环境:
服务器A:172.21.1.30
服务器B:172.21.1.40
两台服务器上分别运行两套Oracle数据库,本实验以scott用户为例进行测试。
实验目的:
通过DB_LINK的复制功能,利用expdp,impdp进行数据的远程备份及恢复。进行测试前,将服务器B上scott用户的dept,emp进行删除,本测试只是使用impdp将服务器A数据库下scott用户的dept,emp表导入到服务器B数据库scott用户下。
操作步骤:
1.在服务器A,B上分别以sys身份登录数据库,并创建directory,db_link,命令如下:
session A: > create directory dp01 as '/bk/dp01';
Directory created.
session A: >create public database link ln_db40 connect to scott identified by tiger using 'ip40';
Database link created.
session A: >grant connect,resource,exp_full_database,imp_full_database to scott identified by tiger;
Grant succeeded.
session B: > create directory dp02 as '/bk/dp02';
Directory created.
session B: >create public database link ln_db30 connect to scott identified by tiger using 'ip30';
Database link created.
session B: >grant connect,resource,exp_full_database,imp_full_database to scott identified by tiger;
Grant succeeded.
2.在确认以上步骤中的db_link没问题后,做以下操作:
a. 服务器A:(将本地数据库中scott用户下的dept,emp两张表导出备份文件为exp01.dmp)
[oracle@session A: dp01]$ expdp scott/tiger directory=dp01 dumpfile=exp01.dmp network_link=ln_db30 tables=emp,dept
Export: Release 10.2.0.1.0 - Production on Wednesday, 03 August, 2011 14:39:05
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_SCHEMA_01": scott/********@ip30 directory=dp01 dumpfile=exp01.dmp network_link=ln_db30 tables=emp,dept
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 320 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/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type SCHEMA_EXPORT/TABLE/COMMENT
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
. . exported "SCOTT"."SYS_EXPORT_SCHEMA_01" 172.8 KB 1073 rows
. . exported "SCOTT"."DEPT" 5.656 KB 4 rows
. . exported "SCOTT"."EMP" 7.820 KB 14 rows
Master table "SCOTT"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SCOTT.SYS_EXPORT_SCHEMA_01 is:
/bk/dp01/exp01.dmp
Job "SCOTT"."SYS_EXPORT_SCHEMA_01" successfully completed at 14:39:37
[oracle@session A: dp01]$ ls
exp01.dmp export.log import.log
b. 将备份文件exp01.dmp从服务器A拷贝到服务器B:
[oracle@session A: dp01]$ scp –r exp01.dmp 172.21.1.40:/bk/dp02/
c.在服务器A上,执行以下命令,将dept,emp表导入到服务器B的scott用户下:
[oracle@session A: dp01]$ impdp scott/tiger@ip40 directory=dp02 dumpfile=exp01.dmp tables=emp,dept
Import: Release 10.2.0.1.0 - Production on Wednesday, 03 August, 2011 14:34:57
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 "SCOTT"."SYS_IMPORT_TABLE_01" successfully loaded/unloaded
Starting "SCOTT"."SYS_IMPORT_TABLE_01": scott/********@ip40 directory=dp02 dumpfile=exp01.dmp tables=emp,dept
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
. . imported "SCOTT"."DEPT" 5.656 KB 4 rows
. . imported "SCOTT"."EMP" 7.820 KB 14 rows
Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX
Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
Job "SCOTT"."SYS_IMPORT_TABLE_01" successfully completed at 14:34:55
3.使用sys用户登录服务器A的数据库,进行测试,查看B的scott用户下的dept,emp表是否存在:
$ sqlplus / as sysdba
session A: > conn scott/tiger
Connected.
session A: > select * from tab;
TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
DEPT TABLE
EMP TABLE
session A: > select * from tab@ln_db40;
TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
DEPT TABLE
EMP TABLE
由以上实验不难看出,表dept,emp已成功导入B的scott用户。
EXPDP 可以导出所有数据库的数据,只要它能连接到这个数据库,或者它登录的数据库
上能读取到被导出的库的数据,因为此时可以通过数据库链来读取被导出的库的数据。
如下测试:
可以分为三个服务器:A,B,,C,以下命令在A在执行:
[oracle@session A: dp01]$ expdp scott/tiger@ip40 directory=dp02 dumpfile=exp01.dmp network_link=ln_db50 tables=emp,dept
Export: Release 10.2.0.1.0 - Production on Wednesday, 03 August, 2011 14:39:05
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_SCHEMA_01": scott/********@ip40 directory=dp02 dumpfile=exp01.dmp network_link=ln_db50 tables=emp,dept
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 320 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/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type SCHEMA_EXPORT/TABLE/COMMENT
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
. . exported "SCOTT"."SYS_EXPORT_SCHEMA_01" 172.8 KB 1073 rows
. . exported "SCOTT"."DEPT" 5.656 KB 4 rows
. . exported "SCOTT"."EMP" 7.820 KB 14 rows
Master table "SCOTT"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SCOTT.SYS_EXPORT_SCHEMA_01 is:
/bk/dp01/exp01.dmp
Job "SCOTT"."SYS_EXPORT_SCHEMA_01" successfully completed at 14:39:37
说明:
expdp 在服务器A上;
scott/tiger@ip40 连接到服务器B的数据库;
network_link=ln_db30 是服务器B的数据库中scott用户的数据库链,其指向服务器C的用户scott,
SCOTT10用户中只有两个表dept,emp.
从上面的操作可以看出:expdp 可以是客户端的程序,但它导出的数据(DMP)必须存放在它登录
的数据库的目录下(本例中,存放在机器B的数据库directory=dp02下),而被导出的数据是通过
数据库链(network_link)到机器C的数据库里读取的。
另外注意:在这过程中,A数据库用户scott和C数据库用户scott(或者数据库链中的用户)都必须被
授予EXP_FULL_DATABASE 权限。
nelwork_link意思是从本地数据库导入datafile直接到remote database,中间省略了exp的操作,
nelwork_link=source_database_link,确认nelwork_link参数是一个存在的目标数据库名称,同时
存在database link.
补充一下两个限制条件:
nelwork_link parameter Restrictions
Network imports do not support the use of evolved types.
a: When the NETWORK_LINK parameter is used in conjunction with the TABLES parameter,
only whole tables can be imported (not partitions of tables).
所以,当使用impdp导入时多张表时,如果添加network_link参数,就会报错如下:
UDI-00011: parameter dumpfile is incompatible with parameter network_link
b: If the USERID that is executing the import job has the IMP_FULL_DATABASE role on the
target database, then that user must also have the EXP_FULL_DATABASE role on the source
database.The only types of database links supported by Data Pump Import are: public,
fixed-user, and connected-user. Current-user database links are not supported.

핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

드림위버 CS6
시각적 웹 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

뜨거운 주제











이 기사는 Docker에서 MySQL 메모리 사용을 최적화합니다. 모니터링 기술 (Docker Stats, Performance Schema, 외부 도구) 및 구성 전략에 대해 설명합니다. 여기에는 Docker 메모리 제한, 스와핑 및 CGroups와 함께 포함됩니다

이 기사에서는 MySQL의 "공유 라이브러리를 열 수 없음"오류를 다룹니다. 이 문제는 MySQL이 필요한 공유 라이브러리 (.so/.dll 파일)를 찾을 수 없음에서 비롯됩니다. 솔루션은 시스템 패키지 M을 통한 라이브러리 설치 확인과 관련이 있습니다.

이 기사는 MySQL의 Alter Table 문을 사용하여 열 추가/드롭 테이블/열 변경 및 열 데이터 유형 변경을 포함하여 테이블을 수정하는 것에 대해 설명합니다.

이 기사는 Linux에 MySQL을 직접 설치하는 것과 Phpmyadmin이없는 Podman 컨테이너 사용을 비교합니다. 각 방법에 대한 설치 단계에 대해 자세히 설명하면서 Podman의 격리, 이식성 및 재현성의 장점을 강조하지만 또한

이 기사는 자체 포함 된 서버리스 관계형 데이터베이스 인 SQLITE에 대한 포괄적 인 개요를 제공합니다. SQLITE의 장점 (단순성, 이식성, 사용 용이성) 및 단점 (동시성 제한, 확장 성 문제)에 대해 자세히 설명합니다. 기음

이 안내서는 Homebrew를 사용하여 MacOS에 여러 MySQL 버전을 설치하고 관리하는 것을 보여줍니다. 홈 브루를 사용하여 설치를 분리하여 갈등을 방지하는 것을 강조합니다. 이 기사에는 설치, 서비스 시작/정지 서비스 및 Best Pra에 대해 자세히 설명합니다

기사는 인증서 생성 및 확인을 포함하여 MySQL에 대한 SSL/TLS 암호화 구성에 대해 설명합니다. 주요 문제는 자체 서명 인증서의 보안 영향을 사용하는 것입니다. [문자 수 : 159]

기사는 MySQL Workbench 및 Phpmyadmin과 같은 인기있는 MySQL GUI 도구에 대해 논의하여 초보자 및 고급 사용자를위한 기능과 적합성을 비교합니다. [159 자].
