在插入資料遇到&時,oracle會認為是個變數,要求輸入值。
原因在於oracle將&定義為自訂變數。SQL> show all
appinfo is OFF and set to "SQL*Plus"
arraysize 15
autocommit OFF
autoprint OFF
autorecovery OFF
autotrace OFF
blockterminator "." (hex 2e)
btitle OFF and is the first few characters of the next SELECT statement
cmdsep OFF
colsep " "
compatibility version NATIVE
concat "." (hex 2e)
copycommit 0
COPYTYPECHECK is ON
define "&" (hex 26)
describe DEPTH 1 LINENUM OFF INDENT ON
echo OFF
editfile "afiedt.buf"
embedded OFF
escape OFF
escchar OFF
......
此時只要set define off,即可插入包含&的值。Using the SET DEFINE OFF Command
To avoid the prompt in the preceding example by using the SET DEFINE OFF command, change the entry to the following:
SET DEFINE OFFCREATE TABLE "Employees & Managers" ( Employees varchar(16), Managers varchar(16));
SET DEFINE OFF
SET DEFINE OFF disables the parsing of commands to replace
substitution variables with their values.
注意:如果是在TOAD中執行,建議在每一個要匯入的指令碼第一行加上前面那句關閉define的話,否則當你匯入第二個含有特殊字元的指令碼的時候,又會出錯。
如果是在SQL*PLUS中執行,則只需要設定一次define OFF,後面就可以連續匯入了。直到你重新設定define ON為止。