Oracle
數據泵導出
我正在嘗試使用 datapump API 導出完整的數據庫,我嘗試使用以下程式碼:
DECLARE handle NUMBER; nom_job varchar(25) := to_char(SYSDATE,'YYYYMMDD_HH24MISS'); nom_dump varchar(25) := nom_job || '.dmp'; nom_log varchar(25) := nom_job || '.log'; BEGIN handle := SYS.DBMS_DATAPUMP.OPEN( operation => 'EXPORT', job_mode => 'FULL', job_name => nom_job ); SYS.DBMS_DATAPUMP.ADD_FILE( handle => handle, filename => nom_dump, directory => 'C:\Backup_folder', filetype => 1 ); SYS.DBMS_DATAPUMP.ADD_FILE( handle => handle, filename => nom_log, directory => 'C:\Backup_folder', filetype => 3 ); SYS.DBMS_DATAPUMP.START_JOB( handle => handle, skip_current => 0, abort_step => 0 ); SYS.DBMS_DATAPUMP.DETACH( handle=> handle ); END;
但它給了我下一個錯誤:
ORA-39001: valeur d'argument non valide ORA-06512: à "SYS.DBMS_SYS_ERROR", ligne 79 ORA-06512: à "SYS.DBMS_DATAPUMP", ligne 2926 ORA-06512: à "SYS.DBMS_DATAPUMP", ligne 3162 ORA-06512: à ligne 21 39001. 00000 - "invalid argument value" *Cause: The user specified API parameters were of the wrong type or value range. Subsequent messages supplied by DBMS_DATAPUMP.GET_STATUS will further describe the error. *Action: Correct the bad argument and retry the API.
第 21 行是:
SYS.DBMS_DATAPUMP.ADD_FILE(
該功能的問題到底在哪裡?
在 ADD_FILE 過程的參數“目錄”中,我應該指定下一個命令創建的目錄的名稱,而不是實際路徑:
create directory backup_folder as 'C:\backup_folder'
PS:ADD_FILE 中指定的目錄名稱應為大寫(大寫字母)。