【EXP】備份複雜關聯查詢後的T表資料
本文是《【EXP】使用EXP的QUERY選項匯出表中部分資料》這篇文章的補充,進一步體現EXP工具在特定條件下匯出資料的功能。
1.T表資料內容如下
sec@secooler> select * from t;
X Y
---------- ---------------------------------
1 sec1
2 sec2
3 sec3
4 sec4
2.建立另外一張關聯表T_REL,並初始化兩條記錄
sec@secooler> create table t_rel (x int);
Table created.
sec@secooler> insert into t_rel values (2);
1 row created.
sec@secooler> insert into t_rel values (3);
1 row created.
sec@secooler> commit;
Commit complete.
sec@secooler> select * From t_rel;
X
----------
2
3
3.我們的目標是使用EXP獲取如下資料
sec@secooler> select t.* from t, t_rel where t.x=t_rel.x;
X Y
---------- -------------------------------
2 sec2
3 sec3
4.方法如下,注意QUERY子句的書寫方法
secooler@secDB /exp$ exp sec/sec file=sec.dmp log=sec.log tables=t query=\"t,t_rel where t.x=t_rel.x\"
Export: Release 11.2.0.1.0 - Production on Mon Mar 8 23:20:00 2010
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
Oracle Database Vault and Real Application Testing option
Export done in AL32UTF8 character set and AL16UTF16 NCHAR character set
server uses ZHS16GBK character set (possible charset conversion)
About to export specified tables via Conventional Path ...
. . exporting table T 2 rows exported
Export terminated successfully without warnings.
5.使用PARFILE引數完成方法如下
1)編輯引數檔案
secooler@secDB /exp$ vi sec.par
userid=sec/sec
file=sec.dmp
log=sec.log
tables=t
query="t,t_rel where t.x=t_rel.x"
~
~
2)使用引數檔案完成資料匯出
secooler@secDB /exp$ exp parfile=sec.par
Export: Release 11.2.0.1.0 - Production on Mon Mar 8 23:27:24 2010
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
Oracle Database Vault and Real Application Testing option
Export done in ZHS16GBK character set and AL16UTF16 NCHAR character set
About to export specified tables via Conventional Path ...
. . exporting table T 2 rows exported
Export terminated successfully without warnings.
6.匯入驗證
sys@secooler> conn sec/sec
Connected.
sec@secooler> delete from t;
4 rows deleted.
sec@secooler> commit;
Commit complete.
sec@secooler> exit
secooler@secDB /exp$ imp sec/sec file=sec.dmp ignore=y full=y
Import: Release 11.2.0.1.0 - Production on Mon Mar 8 23:30:30 2010
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
Oracle Database Vault and Real Application Testing option
Export file created by EXPORT:V11.02.00 via conventional path
import done in ZHS16GBK character set and AL16UTF16 NCHAR character set
. importing SEC's objects into SEC
. importing SEC's objects into SEC
. . importing table "T" 2 rows imported
Import terminated successfully without warnings.
secooler@secDB /exp$ sqlplus sec/sec
SQL*Plus: Release 11.2.0.1.0 Production on Mon Mar 8 23:31:53 2010
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
Oracle Database Vault and Real Application Testing options
sec@secooler> select * from t;
X Y
---------- --------------------
2 sec2
3 sec3
成功,驗證完畢
7.小結
在使用EXP完成複雜關係條件下資料匯出時,尤其要注意在不同作業系統平臺上的轉義方法。建議使用引數檔案(結合PARFILE引數使用)規避這個不大不小的問題。
Good luck.
secooler
10.03.13
-- The End --
1.T表資料內容如下
sec@secooler> select * from t;
X Y
---------- ---------------------------------
1 sec1
2 sec2
3 sec3
4 sec4
2.建立另外一張關聯表T_REL,並初始化兩條記錄
sec@secooler> create table t_rel (x int);
Table created.
sec@secooler> insert into t_rel values (2);
1 row created.
sec@secooler> insert into t_rel values (3);
1 row created.
sec@secooler> commit;
Commit complete.
sec@secooler> select * From t_rel;
X
----------
2
3
3.我們的目標是使用EXP獲取如下資料
sec@secooler> select t.* from t, t_rel where t.x=t_rel.x;
X Y
---------- -------------------------------
2 sec2
3 sec3
4.方法如下,注意QUERY子句的書寫方法
secooler@secDB /exp$ exp sec/sec file=sec.dmp log=sec.log tables=t query=\"t,t_rel where t.x=t_rel.x\"
Export: Release 11.2.0.1.0 - Production on Mon Mar 8 23:20:00 2010
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
Oracle Database Vault and Real Application Testing option
Export done in AL32UTF8 character set and AL16UTF16 NCHAR character set
server uses ZHS16GBK character set (possible charset conversion)
About to export specified tables via Conventional Path ...
. . exporting table T 2 rows exported
Export terminated successfully without warnings.
5.使用PARFILE引數完成方法如下
1)編輯引數檔案
secooler@secDB /exp$ vi sec.par
userid=sec/sec
file=sec.dmp
log=sec.log
tables=t
query="t,t_rel where t.x=t_rel.x"
~
~
2)使用引數檔案完成資料匯出
secooler@secDB /exp$ exp parfile=sec.par
Export: Release 11.2.0.1.0 - Production on Mon Mar 8 23:27:24 2010
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
Oracle Database Vault and Real Application Testing option
Export done in ZHS16GBK character set and AL16UTF16 NCHAR character set
About to export specified tables via Conventional Path ...
. . exporting table T 2 rows exported
Export terminated successfully without warnings.
6.匯入驗證
sys@secooler> conn sec/sec
Connected.
sec@secooler> delete from t;
4 rows deleted.
sec@secooler> commit;
Commit complete.
sec@secooler> exit
secooler@secDB /exp$ imp sec/sec file=sec.dmp ignore=y full=y
Import: Release 11.2.0.1.0 - Production on Mon Mar 8 23:30:30 2010
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
Oracle Database Vault and Real Application Testing option
Export file created by EXPORT:V11.02.00 via conventional path
import done in ZHS16GBK character set and AL16UTF16 NCHAR character set
. importing SEC's objects into SEC
. importing SEC's objects into SEC
. . importing table "T" 2 rows imported
Import terminated successfully without warnings.
secooler@secDB /exp$ sqlplus sec/sec
SQL*Plus: Release 11.2.0.1.0 Production on Mon Mar 8 23:31:53 2010
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
Oracle Database Vault and Real Application Testing options
sec@secooler> select * from t;
X Y
---------- --------------------
2 sec2
3 sec3
成功,驗證完畢
7.小結
在使用EXP完成複雜關係條件下資料匯出時,尤其要注意在不同作業系統平臺上的轉義方法。建議使用引數檔案(結合PARFILE引數使用)規避這個不大不小的問題。
Good luck.
secooler
10.03.13
-- The End --
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/519536/viewspace-629464/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- DataSet多表關聯實現本地資料複雜的查詢
- oracle表複雜查詢Oracle
- 複雜查詢—子查詢
- Mongodb 關聯表查詢MongoDB
- oracle資料庫備份之exp增量備份Oracle資料庫
- 效能優化|多複雜表關聯查詢,你必須要知道的檢索姿勢!優化
- 使用閃回查詢備份資料
- oracle 雜湊查詢與巢狀查詢跟表的先後關係測試Oracle巢狀
- Spring JPA聯表情況下的複雜查詢Spring
- SQL 複雜查詢SQL
- SQL複雜查詢SQL
- 【PHP資料結構】雜湊表查詢PHP資料結構
- 使用 Redis 解決“樹”形資料的複雜查詢Redis
- mysql 三表關聯查詢MySql
- mysql三表關聯查詢MySql
- 查詢(3)--雜湊表(雜湊查詢)
- T-SQL——關於表資料的複製插入SQL
- JPA的多表複雜查詢
- sql查詢一張表的重複資料SQL
- hyperf關聯子表查詢主表資料
- 資料庫AR之關聯查詢資料庫
- 異構資料庫的關聯查詢 oracle hsodbc 關聯mysql資料庫OracleMySql
- Oracle複雜查詢(三)Oracle
- exp匯出一個表中符合查詢條件的資料
- mysql三張表關聯查詢MySql
- SQL三表左關聯查詢SQL
- 兩表關聯查詢:sql、mybatisSQLMyBatis
- Solr複雜查詢一:函式查詢Solr函式
- Laravel使用MongoDB複雜的查詢LaravelMongoDB
- 複雜查詢語句的使用
- 備份後,對資料庫的穩定性檢查資料庫
- mysql查詢表裡的重複資料方法和刪除重複資料MySql
- MaxCompute複雜資料分佈的查詢優化實踐優化
- mysql連表查詢出現資料重複MySql
- Spring Data Jpa 複雜查詢總結 (多表關聯 以及 自定義分頁 )Spring
- MYSQL A、B表陣列關聯查詢MySql陣列
- mysql三表關聯查詢練習MySql
- SpringBoot JPA 表關聯查詢Spring Boot