exp\imp 遇到作業系統轉移字元問題(比如query引數裡的where)
from:baidu.com
String
cmd="exp 使用者名稱/密碼@服務名
file=C:\20111226160758.dmp tables=(表名)
query=\\\"where ADDTIME>=to_date('2011-12-01 15:56:46','YYYY-MM-DD
hh24:mi:ss') and ADDTIME<=to_date('2011-12-26 15:56:46','YYYY-MM-DD
hh24:mi:ss')\\\"";(win7測試透過)
//如果是windows os?
cmd="cmd /c "+cmd;
//如果是linux os
boolean
shouldClose=false;
Process process=null;
try {
process = java.lang.Runtime.getRuntime().exec("cmd /c
"+cmd);
BufferedReader b = new BufferedReader(new
InputStreamReader(process.getErrorStream()));
String line = null;
boolean err=false;
errinfo="";
while((line=b.readLine())!=null)
{
System.out.println(line);
if(err)
{
errinfo=line;
process.destroy();
break;
}
if(line.indexOf("錯誤")>0)
{
err=true;
}
}
int value= process.exitValue();
if(value==0||(value==3&&!err))
{
this.setOperateStatus("資料庫備份完成");
System.out.println("資料庫備份完成!");
}
else
{
System.out.println("exit value =" + value);
System.out.println("資料庫備份失敗!");
this.setOperateStatus("資料庫備份失敗");
}
shouldClose=true;
if(shouldClose)
process.destroy();
} catch (IOException e) {
// TODO Auto-generated catch block
shouldClose=true;
e.printStackTrace();
}finally{
try {
if(process!=null)
process.waitFor();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
query 引數說明
其實文件中講得很清楚:
exp
scott/tiger TABLES=emp QUERY=\"WHERE job=\'SALESMAN\' and sal
\<1600\"Note:
Because the value of the QUERY parameter contains blanks, most operating
systems require that the entire strings WHERE job=\'SALESMAN\' and sal\<1600
be placed in double quotation marks or marked as a literal by some method.
Operating system reserved characters also need to be preceded by an escape
character. See your Oracle operating system-specific documentation for
information about special and reserved characters on your system.
所有作業系統保留字元都要使用轉義符號,看來 ( ) 也需要轉義。
正確的寫法:
exp scott/tiger tables=skytest file=test.dmp query=\"where dt=to_date\(\'2007-09-22\',\'yyyy-mm-dd\'\)\" (linux)
exp scott/tiger tables=skytest file=test.dmp query=\"where dt=to_date('2007-09-22','yyyy-mm-dd')\" (win7)
任何 os 平臺都適用的方法(推薦):
使用 parfile 就不用擔心這些格式問題
oracle
DBALNP01 > cat > test.par
tables=skytest
file=test.dmp
query="where dt=to_date('2007-09-22','yyyy-mm-dd')"
oracle DBALNP01 > exp / parfile=test.par
Export: Release 8.1.7.4.0 - Production on Wed Sep 12 04:22:27 2007
(c) Copyright 2000 Oracle Corporation. All rights reserved.
Connected to: Oracle8i Enterprise Edition Release 8.1.7.4.0 - Production
With the Partitioning option
JServer Release 8.1.7.4.0 - Production
Export done in US7ASCII character set and US7ASCII NCHAR character set
About
to export specified tables via Conventional Path ...
. . exporting
table
SKYTEST 1 rows exported
Export terminated successfully without warnings.
不需要任何轉義符既簡潔又可以在多種作業系統平臺上通用,推薦使用這種方式。
?命令列exp 匯出時對密碼中含“)”的處理方法
使用者的密碼為Rdy)Jl!S
在windows D:>exp testuser/Rdy)Jl!S@oralocal owner=testuser
在linux nunix下,用""
$ exp "testuser/Rdy)Jl!S" owner=testuser
IMPDP FLASHBACK_TIME 中如何使用TO_TIMESTAMP引數,防止LRM-00116
官方文件上查,引數檔案中這樣寫"to_timestamp()"
在命令列中直接這樣寫
C:\Documents
and Settings\yyy>impdp scott/tiger tables=t directory=exp_dir
network_link=test flashback_time="to_timestamp('2009-01-07 2
0:01:22','yyyy-mm-dd hh24:MI:SS')"
LRM-00116: ')'後跟
'yyyy-mm-dd hh24:' 時出現語法錯誤
總提示語法錯誤
後來N長時間終於找到了解決辦法
Alternatively
you can used FLASHBACK_TIME parameter like on unix,
flashback_time=\"TO_TIMESTAMP\(\'16-05-2008 11:21:42\', \'DD-MM-YYYY
HH24:MI:SS\'\)\"
On windows,
flashback_time=\"TO_TIMESTAMP('16-05-2008 13:24:26', 'DD-MM-YYYY
HH24:MI:SS')\"
Use backslash(\) before
special character.
所以改成
C:\Documents
and Settings\jiachliu>impdp scott/tiger tables=t directory=exp_dir
network_link=test flashback_time=\"to_timestamp('2009-01-07
20:01:22','yyyy-mm-dd hh24:MI:SS')\"
執行成功
--END
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/27042095/viewspace-1080708/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 使用imp/exp遇到兩個問題
- 【exp/imp不同版本】Oracle不同版本的exp/imp使用注意事項Oracle
- oracle exp和impOracle
- exp和imp詳解
- exp&imp的使用方法
- 用exp、imp遷移包含物化檢視日誌的資料
- exp匯出遭遇IMP-00020
- [20190520]exp imp on th fly.txt
- 異數OS談發展國產作業系統的問題作業系統
- 計算機作業系統|作業系統引論計算機作業系統
- 提交Spark作業遇到的NoSuchMethodError問題總結SparkError
- 不同版本exp/imp使用注意事項
- DBA不可不知的作業系統核心引數作業系統
- 系統引數nofile設定不生效問題
- linux安裝DB2之前的作業系統引數LinuxDB2作業系統
- oracle資料匯出匯入(exp/imp)Oracle
- 分散式系統遇到的十個問題分散式
- 【求助各位大佬】【急】pytest 動態引數化遇到的問題
- 關於 Laravel 遷移遇到的問題Laravel
- 直播系統開發遇到的三大問題
- 多端引數不統一問題
- 關於mysql字元和數字型別轉換的問題研究MySql字元型別
- EXP、IMP、SQLLOADER、EXPDP、IMPDP、DBMS_METADATA、SQLPLUS等方面SQL
- vue3 setup裡獲取query params路由攜帶的引數Vue路由
- nuxt 過濾 query 引數UX
- Windows10 作業系統裡數量眾多的 svchost.exeWindows作業系統
- FPGA的DAC轉換部分遇到的問題FPGA
- 作業系統面試題作業系統面試題
- 作業系統--錯題集作業系統
- Windows作業系統常見故障問題和解決方案Windows作業系統
- LOG巨集的引數問題
- 企業可以自己開發OA系統嗎?會遇到什麼問題?
- 企業在使用點晴OA系統遇到操作問題如何解決?
- exp匯出報錯EXP-00106問題處理
- 前端開發過程常見問題,比如JavaScript變數的提升前端JavaScript變數
- scheme跳轉特殊字元編碼問題Scheme字元
- MySQL like查詢字元轉義遇到的坑MySql字元
- 在Ubuntu作業系統裡安裝DockerUbuntu作業系統Docker
- 作業系統習題以及答案作業系統