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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle exp query引數 轉義符的各個作業系統通用解決方法Oracle作業系統
- 轉:oracle EXP /IMP引數詳解Oracle
- oracle密碼特殊字元在imp、exp裡的使用Oracle密碼字元
- AIX作業系統shell的引數(轉)AI作業系統
- imp/EXP 表空間轉換問題
- IMP EXP常用引數,實用例子
- Oracle Exp/Imp常見問題Oracle
- imp中的indexfile引數解決imp指定表空間問題Index
- exp,imp 遷移資料
- imp/exp資料遷移
- 大表exp/imp遷移
- Exp和資料泵(Data Pump)的query引數使用
- AIX作業系統核心引數配置AI作業系統
- imp exp 跨系統匯入案例
- 如何利用errorstack分析exp或imp問題Error
- exp/imp expdp/impdp Tables 萬用字元 % 的使用字元
- exp/imp處理在32位作業系統上大於2G的資料作業系統
- 轉:EXP 資料庫資料 QUERY 選項使用問題資料庫
- 異數OS談發展國產作業系統的問題作業系統
- 【IMP】使用IMP的SHOW引數輕鬆獲取EXP命令的DUMP檔案內容
- Oracle exp/imp字符集相關問題Oracle
- 計算機作業系統|作業系統引論計算機作業系統
- [20171105]exp imp buffer引數解析.txt
- DBA不可不知的作業系統核心引數作業系統
- 提交Spark作業遇到的NoSuchMethodError問題總結SparkError
- 轉:Exp/Imp工具效能調優
- imp/exp 字符集轉換
- timesten 11.2.2 作業系統核心引數配置作業系統
- exp匯出compress引數導致的imp時擴充套件太大套件
- impdp遇到char字元含中文的問題字元
- exp/imp expdp/impdp Tables 萬用字元 % 的使用【Blog 搬家】字元
- 雙硬碟grub引導9個作業系統(轉)硬碟作業系統
- 探索Oracle之 EXP/IMP過程中的字符集問題Oracle
- 在AIX作業系統下shell的變數(轉)AI作業系統變數
- 作業系統的程式/執行緒同步問題作業系統執行緒
- exp/imp工具
- Oracle imp/expOracle
- BREW常見問題解答(FAQ 4)-語言和作業系統 (轉)作業系統