使用DBMS_FILE_TRANSFER解決無許可權讀取dump檔案問題
經常碰到這樣的問題,有許可權使用expdp匯出檔案(owner為oracle,other無讀許可權),但沒許可權讀取匯出檔案。
使用DBMS_FILE_TRANSFER包可以繞過該限制,測試如下:
1,匯出檔案無許可權讀取
[bnet@SHPAM013:/bnet/exp_data]$ uname -a
AIX SHPAM013 3 5 00F710654C00
AIX SHPAM013 3 5 00F710654C00
[bnet@SHPAM013:/bnet/exp_data]$ ls -lrt *.dmp
-rw-r----- 1 oracle dba 21667840 Dec 31 10:19 tmp_accounts_ef0109.dmp
2,使用COPY_FILE複製檔案,許可權不變,不能讀取:
BEGIN
DBMS_FILE_TRANSFER.COPY_FILE('DATA_PLATFORM_OVERSEA','tmp_accounts_ef0109.dmp', 'DATA_PLATFORM_OVERSEA',
'a.dmp');
END;
/
PL/SQL procedure successfully completed.
BEGIN
DBMS_FILE_TRANSFER.COPY_FILE('DATA_PLATFORM_OVERSEA','tmp_accounts_ef0109.dmp', 'DATA_PLATFORM_OVERSEA',
'a.dmp');
END;
/
PL/SQL procedure successfully completed.
SQL> host ls -lrt *.dmp
-rw-r----- 1 oracle dba 21667840 Dec 31 10:19 tmp_accounts_ef0109.dmp
-rw-r----- 1 oracle dba 21667840 Jan 20 15:11 a.dmp
3,使用GET_FILE在本機複製檔案,許可權不變,不能讀取:
create database link aaa
connect to bnet303 IDENTIFIED BY bnet303
using '(DESCRIPTION=
(LOAD_BALANCE=ON)
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521))
)
(CONNECT_DATA=
(SERVICE_NAME=orau10g)
)
)';
BEGIN
DBMS_FILE_TRANSFER.GET_FILE('DATA_PLATFORM_OVERSEA','a.dmp', 'AAA','DATA_PLATFORM_OVERSEA',
'b.dmp');
END;
/
DBMS_FILE_TRANSFER.GET_FILE('DATA_PLATFORM_OVERSEA','a.dmp', 'AAA','DATA_PLATFORM_OVERSEA',
'b.dmp');
END;
/
SQL> host ls -lrt *.dmp
-rw-r----- 1 oracle dba 21667840 Dec 31 10:19 tmp_accounts_ef0109.dmp
-rw-r----- 1 oracle dba 21667840 Jan 20 15:11 a.dmp
-rw-r----- 1 oracle dba 21667840 Jan 20 16:24 b.dmp
4,使用GET_FILE把檔案複製到有Oracle許可權的資料庫伺服器上:
[oracle@bnet95 ~]$ uname -a
Linux bnet95 2.6.18-164.el5xen #1 SMP Thu Sep 3 04:47:32 EDT 2009 i686 i686 i386 GNU/Linux
Linux bnet95 2.6.18-164.el5xen #1 SMP Thu Sep 3 04:47:32 EDT 2009 i686 i686 i386 GNU/Linux
4.1 複製
create database link aaa
connect to bnet303 IDENTIFIED BY bnet303
using '(DESCRIPTION=
(LOAD_BALANCE=ON)
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=TCP)(HOST=22.188.20.138)(PORT=1521))
)
(CONNECT_DATA=
(SERVICE_NAME=orau10g)
)
)';
create database link aaa
connect to bnet303 IDENTIFIED BY bnet303
using '(DESCRIPTION=
(LOAD_BALANCE=ON)
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=TCP)(HOST=22.188.20.138)(PORT=1521))
)
(CONNECT_DATA=
(SERVICE_NAME=orau10g)
)
)';
BEGIN
DBMS_FILE_TRANSFER.GET_FILE('DATA_PLATFORM_OVERSEA','a.dmp', 'AAA','MYDIR',
'b.dmp');
END;
/
[oracle@bnet95 ~]$ ls -lrt b.dmp
-rw-r----- 1 oracle oinstall 21667840 Oct 9 16:33 b.dmp
-rw-r----- 1 oracle oinstall 21667840 Oct 9 16:33 b.dmp
4.2 匯入
[oracle@bnet95 ~]$ impdp mh/mh directory=mydir dumpfile=b.dmp sqlfile=b.sql full=y
Import: Release 10.2.0.1.0 - Production on Monday, 09 October, 2028 16:35:50
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 "MH"."SYS_SQL_FILE_FULL_01" successfully loaded/unloaded
Starting "MH"."SYS_SQL_FILE_FULL_01": mh/******** directory=mydir dumpfile=b.dmp sqlfile=b.sql full=y
Processing object type TABLE_EXPORT/TABLE/TABLE
Job "MH"."SYS_SQL_FILE_FULL_01" successfully completed at 16:36:01
With the Partitioning, OLAP and Data Mining options
Master table "MH"."SYS_SQL_FILE_FULL_01" successfully loaded/unloaded
Starting "MH"."SYS_SQL_FILE_FULL_01": mh/******** directory=mydir dumpfile=b.dmp sqlfile=b.sql full=y
Processing object type TABLE_EXPORT/TABLE/TABLE
Job "MH"."SYS_SQL_FILE_FULL_01" successfully completed at 16:36:01
[oracle@bnet95 ~]$ more b.sql
-- CONNECT MH
-- new object type path is: TABLE_EXPORT/TABLE/TABLE
CREATE TABLE "bnet303"."TMP_ACCOUNTS_EF0109"
( "ACTNUM" VARCHAR2(24)
) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "bnetOVS_TBS" ;
-- CONNECT MH
-- new object type path is: TABLE_EXPORT/TABLE/TABLE
CREATE TABLE "bnet303"."TMP_ACCOUNTS_EF0109"
( "ACTNUM" VARCHAR2(24)
) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "bnetOVS_TBS" ;
[oracle@bnet95 ~]$ impdp mh/mh full=y directory=mydir dumpfile=b.dmp remap_schema=bnet303:MH remap_tablespace=bnetOVS_TBS:USERS
Import: Release 10.2.0.1.0 - Production on Monday, 09 October, 2028 16:39:59
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 "MH"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
Starting "MH"."SYS_IMPORT_FULL_01": mh/******** full=y directory=mydir dumpfile=b.dmp remap_schema=bnet303:MH remap_tablespace=bnetOVS_TBS:USERS
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
. . imported "MH"."TMP_ACCOUNTS_EF0109" 20.60 MB 1269546 rows
Job "MH"."SYS_IMPORT_FULL_01" successfully completed at 16:40:08
With the Partitioning, OLAP and Data Mining options
Master table "MH"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
Starting "MH"."SYS_IMPORT_FULL_01": mh/******** full=y directory=mydir dumpfile=b.dmp remap_schema=bnet303:MH remap_tablespace=bnetOVS_TBS:USERS
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
. . imported "MH"."TMP_ACCOUNTS_EF0109" 20.60 MB 1269546 rows
Job "MH"."SYS_IMPORT_FULL_01" successfully completed at 16:40:08
4.3 匯入資料驗證
SQL> select count(*) from TMP_ACCOUNTS_EF0109;
COUNT(*)
----------
1269546
----------
1269546
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/18922393/viewspace-756658/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- WPF + Winform 解決管理員許可權下無法拖放檔案的問題ORM
- hdfs檔案本地許可權問題
- linux檔案許可權問題Linux
- 用無程式碼解決CRM角色許可權問題
- vue許可權問題解決方案Vue
- Laravel 日誌檔案許可權問題Laravel
- 通過設定目錄組標誌位解決dmp檔案讀許可權問題
- ubuntu下解決wireshark許可權問題Ubuntu
- 解決root使用者對HDFS檔案系統沒有許可權的問題
- 關於oracle檔案許可權的問題Oracle
- 解決samba只讀,但無修改許可權的配置Samba
- 解決在Windows10下沒有許可權修改hosts檔案的問題Windows
- ssh無法登入——許可權問題如何解決
- 解決從linux本地檔案系統上傳檔案到HDFS時的許可權問題Linux
- Linux更改檔案及目錄許可權問題Linux
- linux檔案許可權 詳解Linux
- Linux檔案許可權詳解Linux
- linux 檔案許可權 s 許可權和 t 許可權解析Linux
- 解讀Linux檔案許可權的設定方法(轉)Linux
- Win7 IIS7 配置錯誤由於許可權不足而無法讀取配置檔案的解決辦法Win7
- 關於移除 .user.ini檔案報錯,提示沒有許可權問題解決方案
- Linux檔案讀、寫、執行許可權Linux
- MySQL許可權問題MySql
- PostgreSQL物件許可權如何在後設資料中獲取-許可權解讀、定製化匯出許可權SQL物件
- win10如何獲取檔案訪問許可權_win10怎麼獲取許可權看資料夾Win10訪問許可權
- 【LIUNX】目錄或檔案許可權,許可權授予
- 解決Windows10沒有修改hosts檔案許可權Windows
- 使用者及檔案許可權管理
- dump 解決問題
- Android SELinux avc dennied許可權問題解決方法AndroidLinux
- oracle 通過trigger解決drop許可權問題Oracle
- Android7.0檔案訪問許可權Android訪問許可權
- Linux檔案許可權Linux
- chomd檔案許可權授予
- 修改檔案的許可權
- oracle許可權整理檔案Oracle
- Linux 檔案許可權Linux
- Atitit godaddy 檔案許可權 root許可權設定Go