您好,登錄后才能下訂單哦!
實(shí)驗(yàn)環(huán)境:
源庫(kù): 192.168.2.200 SID=testdb
目標(biāo)庫(kù):192.168.2.100 SID=testdb
實(shí)驗(yàn)?zāi)康模?/p>
使用impdp+dblink的方式 將192.168.2.200數(shù)據(jù)庫(kù)上的jtrms用戶(hù)的所有數(shù)據(jù)導(dǎo)入到目標(biāo)數(shù)據(jù)庫(kù)192.168.2.100
注意:使用impdp+dblink 的方式,這樣就節(jié)省了數(shù)據(jù)導(dǎo)出(expdp),然后再導(dǎo)入的過(guò)程。
實(shí)施步驟:
一、源庫(kù)操作:
1、首先檢查源庫(kù)要遷移的用戶(hù)信息:
SQL> select USERNAME,DEFAULT_TABLESPACE from dba_users where USERNAME like 'JTRMS'; ---檢查用戶(hù)的默認(rèn)表空間
USERNAME DEFAULT_TABLESPACE
------------------------------ ------------------------------
JTRMS TEST
2、該用戶(hù)的表空間大小
SQL> select TABLESPACE_NAME,BYTES from dba_data_files where TABLESPACE_NAME like 'TEST';
TABLESPACE_NAME BYTES
------------------------------ ----------
TEST 314572800
SQL> show user;
USER is "JTRMS"
SQL> select * from tab; ----檢查該用戶(hù)一共有97張表
TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
ECR_ANNOUNCEMENT TABLE
ECR_APPROVAL TABLE
ECR_APPROVAL_TO_RECEIVE TABLE
ECR_BP_SYN TABLE
ECR_CHANGE TABLE
JFORUM_THEMES TABLE
JFORUM_TOPICS TABLE
JFORUM_TOPICS_WATCH TABLE
JFORUM_USERS TABLE
JFORUM_USER_GROUPS TABLE
JFORUM_VOTE_DESC TABLE
JFORUM_VOTE_RESULTS TABLE
JFORUM_VOTE_VOTERS TABLE
JFORUM_WORDS TABLE
SYS_TEMP_FBT TABLE
。。。。。。。
。。。。。。。
97 rows selected.
3、查看該用戶(hù)下的索引信息:
SQL> set linesize 300 pagesize 300
SQL> select INDEX_NAME,TABLE_OWNER,STATUS,NUM_ROWS from user_indexes;
4、查看該用戶(hù)下所有的job信息
alter session set nls_date_format = 'yyyy-mm-dd hh34:mi:ss';
set linesize 300 pagesize 300
col what for a50
col interval for a50
select job,what,LAST_DATE,NEXT_DATE,SCHEMA_USER,interval from user_jobs;
二、在目標(biāo)數(shù)據(jù)庫(kù)上操作
注意:在目標(biāo)數(shù)據(jù)庫(kù)創(chuàng)建用戶(hù)信息之前,一定要檢查目標(biāo)看是否有該用戶(hù)的信息,和表空間是否有重名等
1、在目標(biāo)數(shù)據(jù)庫(kù)上創(chuàng)建用戶(hù)信息---一切以源庫(kù)為標(biāo)準(zhǔn)
SQL> create tablespace test datafile '/opt/oracle/test.dbf' size 300M; ---創(chuàng)建test表空間
SQL> create user jtrms identified by jtrms default tablespace test; ---創(chuàng)建jtrms用戶(hù)
SQL> grant connect,resource to jtrms; ---對(duì)該用戶(hù)授權(quán)
SQL> grant dba to jtrms;
2、在目標(biāo)數(shù)據(jù)庫(kù)增加源庫(kù)的tns文件信息,并測(cè)試連接源庫(kù)
[oracle@test ~]$ vim tnsnames.ora
testdb =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.200)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = testdb)
)
)
---注意,增加的是源庫(kù)192.168.2.200的信息
[oracle@test ~]$ sqlplus jtrms/jtrms@testdb ; ----使用jtrms用戶(hù)連接源庫(kù)192.168.2.200
SQL*Plus: Release 11.2.0.4.0 Production on Mon Jun 5 00:54:31 2017
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select instance_name from v$instance;
INSTANCE_NAME
----------------
testdb
3、在目標(biāo)數(shù)據(jù)庫(kù)上創(chuàng)建dblink
create public database link testlink connect to jtrms identified by jtrms
using '(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.200)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = testdb)
)
)';
注意:該dblink是連接源庫(kù)用的
4、在目標(biāo)數(shù)據(jù)庫(kù)上,開(kāi)始使用下面的命令將源庫(kù)jtrms用戶(hù)的數(shù)據(jù)使用dblink導(dǎo)入到目標(biāo)庫(kù)
[oracle@test ~]$ impdp jtrms network_link=testlink schemas=jtrms cluster=N PARALLEL=2
Import: Release 11.2.0.4.0 - Production on Mon Jun 5 01:03:16 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Password: ---輸入用戶(hù)的密碼
5、登錄數(shù)據(jù)庫(kù),驗(yàn)證數(shù)據(jù)是否傳輸成功:
[oracle@test ~]$ sqlplus '/as sysdba'
SQL*Plus: Release 11.2.0.4.0 Production on Mon Jun 5 01:06:34 2017
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> conn jtrms/jtrms
SQL> select count(*) from tab;
COUNT(*)
----------
97
SQL> set linesize 300 pagesize 300
SQL> select INDEX_NAME,TABLE_OWNER,STATUS,NUM_ROWS from user_indexes;
INDEX_NAME TABLE_OWNER STATUS NUM_ROWS
------------------------------ ------------------------------ -------- ----------
IDX_BOK_REL JTRMS VALID 0
IDX_BOK_USER JTRMS VALID 0
SYS_C0011373 JTRMS VALID 0
SYS_C0011372 JTRMS VALID 0
IDX_BANLIST_EMAIL JTRMS VALID 0
-----至此,實(shí)施完成;
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。