【實驗】【外部表】以資料泵檔案格式抽取and遷移資料演示
值此實驗演示一種外部表的新用法。
1.為了實驗方便,在根目錄“/”下建立datapump目錄,存放從資料庫中解除安裝成資料泵格式的資料
[root@testdb /]# mkdir datapump
[root@testdb /]# chown -R oracle:oinstall datapump
[root@testdb /]# ls -ld datapump
drwxr-xr-x 2 oracle oinstall 4096 08-06 13:25 datapump
2.建立目錄datapump
sec@ora10g> create or replace directory datapump as '/datapump';
Directory created.
3.待解除安裝表t_test的建立及樣本資料
sec@ora10g> create table t_test (id int, name varchar2(10));
sec@ora10g> insert into t_test values (1,'Andy');
sec@ora10g> insert into t_test values (2,'Secooler');
sec@ora10g> insert into t_test values (3,'Hou');
sec@ora10g> commit;
sec@ora10g> select * from t_test;
ID NAME
---------- ----------
1 Andy
2 Secooler
3 Hou
4.解除安裝表t_test中的資料到作業系統檔案/datapump/t_test.dat中
sec@ora10g> create table unload_t_test
2 organization external
3 ( type oracle_datapump
4 default directory datapump
5 location( 't_test.dat' )
6 )
7 as
8 select * from t_test;
OK,透過上面的方法,我們就把t_test表中的資料“轉儲到了”作業系統上。
5.檢視一下解除安裝到的/datapump/t_test.dat檔案中的內容
1)使用ls命令可以看到我們解除安裝到的t_test.dat檔案和日誌檔案
ora10g@testdb /datapump$ ls -l
total 16
-rw-r--r-- 1 oracle oinstall 41 Aug 6 13:54 UNLOAD_T_TEST_10836.log
-rw-r----- 1 oracle oinstall 12288 Aug 6 13:54 t_test.dat
2)日誌檔案的內容非常的簡單,如下:
ora10g@testdb /datapump$ cat UNLOAD_T_TEST_10836.log
LOG file opened at 08/06/09 13:54:06
3)重點看一下解除安裝得到的物理檔案t_test.dat的內容:
ora10g@testdb /datapump$ strings t_test.dat
x86_64/Linux 2.4.xx
WE8ISO8859P1
LBB EMB GHC JWD SD EBE WMF DDG JG SJH SRH JGK CL EGM BJM RAP RLP RP KR PAR MS MRS JLS CET HLT
10.02.00.01.00
|
1
0
3
0
WE8ISO8859P1
AL16UTF16
+08:00
SEC
UNLOAD_T_TEST
1
0
ID
2
22
0
-127
0
0
0
2
0
NAME
1
10
0
0
31
1
10
Andy<
Secooler<
ora10g@testdb /datapump$
透過使用strings命令得到的全部內容展示在上面,可以看到,格式是XML的,這也是使用外部表解除安裝得到檔案格式,XML格式的檔案使用上非常的靈活。
6.此時的表unload_t_test引用的資料就是作業系統上t_test.dat檔案的內容了
sec@ora10g> select * from unload_t_test;
ID NAME
---------- ----------
1 Andy
2 Secooler
3 Hou
(id int, name varchar2(10))
7.在我的這個實驗環境中還有另外一個名為secooler的例項,我們在secooler例項中透過外部表的形式讀取剛剛轉儲的t_test.dat檔案,表現一下資料遷移的味道
1)指定例項名
ora10g@testdb /datapump$ export ORACLE_SID=secooler
2)進入到andy使用者,目標是在andy使用者中可以讀到t_test.dat檔案的內容
secooler@testdb /datapump$ sqlplus andy/andy
SQL*Plus: Release 10.2.0.1.0 - Production on Thu Aug 6 14:16:39 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options
andy@secooler>
3)因為是全新的例項,所以需要重新建立目錄,為了與上面的區別,這裡我們將目錄的名字命名為datapump_secooler,但目錄還是要指定到/datapump
andy@secooler> create or replace directory datapump_secooler as '/datapump';
Directory created.
4)建立外部表t_secooler直接讀取檔案t_test.dat的內容
create table t_secooler (id int, name varchar2(10))
organization external
( type oracle_datapump
default directory datapump_secooler
location( 't_test.dat')
)
/
5)檢視外部表t_secooler的內容
andy@secooler> select * from t_secooler;
ID NAME
---------- ----------
1 Andy
2 Secooler
3 Hou
6)很神奇吧,已經以只讀的方式檢視到了t_test.dat的內容
8.總結
這個特性是在10g Release 1版本中提供的。妙趣橫生ing,提供給我們有一種遷移資料的途徑。
secooler
09.08.06
-- The End --
1.為了實驗方便,在根目錄“/”下建立datapump目錄,存放從資料庫中解除安裝成資料泵格式的資料
[root@testdb /]# mkdir datapump
[root@testdb /]# chown -R oracle:oinstall datapump
[root@testdb /]# ls -ld datapump
drwxr-xr-x 2 oracle oinstall 4096 08-06 13:25 datapump
2.建立目錄datapump
sec@ora10g> create or replace directory datapump as '/datapump';
Directory created.
3.待解除安裝表t_test的建立及樣本資料
sec@ora10g> create table t_test (id int, name varchar2(10));
sec@ora10g> insert into t_test values (1,'Andy');
sec@ora10g> insert into t_test values (2,'Secooler');
sec@ora10g> insert into t_test values (3,'Hou');
sec@ora10g> commit;
sec@ora10g> select * from t_test;
ID NAME
---------- ----------
1 Andy
2 Secooler
3 Hou
4.解除安裝表t_test中的資料到作業系統檔案/datapump/t_test.dat中
sec@ora10g> create table unload_t_test
2 organization external
3 ( type oracle_datapump
4 default directory datapump
5 location( 't_test.dat' )
6 )
7 as
8 select * from t_test;
OK,透過上面的方法,我們就把t_test表中的資料“轉儲到了”作業系統上。
5.檢視一下解除安裝到的/datapump/t_test.dat檔案中的內容
1)使用ls命令可以看到我們解除安裝到的t_test.dat檔案和日誌檔案
ora10g@testdb /datapump$ ls -l
total 16
-rw-r--r-- 1 oracle oinstall 41 Aug 6 13:54 UNLOAD_T_TEST_10836.log
-rw-r----- 1 oracle oinstall 12288 Aug 6 13:54 t_test.dat
2)日誌檔案的內容非常的簡單,如下:
ora10g@testdb /datapump$ cat UNLOAD_T_TEST_10836.log
LOG file opened at 08/06/09 13:54:06
3)重點看一下解除安裝得到的物理檔案t_test.dat的內容:
ora10g@testdb /datapump$ strings t_test.dat
x86_64/Linux 2.4.xx
WE8ISO8859P1
LBB EMB GHC JWD SD EBE WMF DDG JG SJH SRH JGK CL EGM BJM RAP RLP RP KR PAR MS MRS JLS CET HLT
10.02.00.01.00
Andy<
Secooler<
ora10g@testdb /datapump$
透過使用strings命令得到的全部內容展示在上面,可以看到,格式是XML的,這也是使用外部表解除安裝得到檔案格式,XML格式的檔案使用上非常的靈活。
6.此時的表unload_t_test引用的資料就是作業系統上t_test.dat檔案的內容了
sec@ora10g> select * from unload_t_test;
ID NAME
---------- ----------
1 Andy
2 Secooler
3 Hou
(id int, name varchar2(10))
7.在我的這個實驗環境中還有另外一個名為secooler的例項,我們在secooler例項中透過外部表的形式讀取剛剛轉儲的t_test.dat檔案,表現一下資料遷移的味道
1)指定例項名
ora10g@testdb /datapump$ export ORACLE_SID=secooler
2)進入到andy使用者,目標是在andy使用者中可以讀到t_test.dat檔案的內容
secooler@testdb /datapump$ sqlplus andy/andy
SQL*Plus: Release 10.2.0.1.0 - Production on Thu Aug 6 14:16:39 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options
andy@secooler>
3)因為是全新的例項,所以需要重新建立目錄,為了與上面的區別,這裡我們將目錄的名字命名為datapump_secooler,但目錄還是要指定到/datapump
andy@secooler> create or replace directory datapump_secooler as '/datapump';
Directory created.
4)建立外部表t_secooler直接讀取檔案t_test.dat的內容
create table t_secooler (id int, name varchar2(10))
organization external
( type oracle_datapump
default directory datapump_secooler
location( 't_test.dat')
)
/
5)檢視外部表t_secooler的內容
andy@secooler> select * from t_secooler;
ID NAME
---------- ----------
1 Andy
2 Secooler
3 Hou
6)很神奇吧,已經以只讀的方式檢視到了t_test.dat的內容
8.總結
這個特性是在10g Release 1版本中提供的。妙趣橫生ing,提供給我們有一種遷移資料的途徑。
secooler
09.08.06
-- The End --
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/519536/viewspace-611493/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 海量資料遷移之外部表並行抽取並行
- 資料庫遷移之資料泵實驗資料庫
- 資料遷移(1)——通過資料泵表結構批量遷移
- 海量資料遷移之外部表切分
- 海量資料遷移之資料抽取流程
- 資料檔案遷移
- 海量資料遷移之外部表載入
- 線上遷移表空間資料檔案
- Oracle 表空間資料檔案遷移Oracle
- 海量資料處理_使用外部表進行資料遷移
- 海量資料處理_資料泵分批資料遷移
- Oracle資料庫(資料泵)遷移方案(上)Oracle資料庫
- Oracle資料庫(資料泵)遷移方案(下)Oracle資料庫
- Mongo資料遷移實驗Go
- 外部表的另一種用途 資料遷移
- 資料檔案的遷移
- oracle 資料檔案遷移Oracle
- oracle資料檔案遷移Oracle
- InnoDB資料表空間檔案平滑遷移
- Oracle使用資料泵 (expdp/impdp)實施遷移Oracle
- 資料泵檔案
- 使用資料泵(expdp、impdp)遷移資料庫流程資料庫
- Oracle_遷移資料檔案Oracle
- 資料庫檔案的遷移資料庫
- (個人)Oracle 表空間資料檔案遷移(轉)Oracle
- 使用impdp,expdp資料泵進入海量資料遷移
- 使用oracle外部表進行資料泵解除安裝資料Oracle
- 從雲資料遷移服務看MySQL大表抽取模式MySql模式
- 【資料遷移】RMAN遷移資料庫到ASM(二)切換資料檔案到ASM資料庫ASM
- 【資料遷移】使用傳輸表空間遷移資料
- 使用資料泵遷移遇到的問題
- 遷移資料庫檔案到ASM資料庫ASM
- 達夢資料庫資料檔案遷移過程資料庫
- 資料泵實現資料遷移到異地庫
- 達夢資料庫系統表空間資料檔案遷移過程資料庫
- 海量資料遷移之分割槽並行抽取並行
- 網頁引入外部css檔案格式演示網頁CSS
- 【移動資料】External Table 外部表