sqlterminator
SQLPLUS的sqlterminator参数可以在后面跟3个东西,分别是ON、OFF和character
SQL> set sqlterminator ON|OFF|c
c specifies the character that ends an SQL statement. The default is the semicolon (;).
The sqlterminator cannot be alpha numeric.
举例如下:
SQL> set sqlterminator off
SQL> show sqlterminator
sqlterminator OFF
SQL> select * from dual
2 ;
3 /
;
*
ERROR at line 2:
ORA-00911: invalid character
SQL> select * from dual
2 /
D
-
X
--关闭之后仅能以"/"来执行该SQL语句
SQL> set sqlterminator on
SQL> show sqlterminator
sqlterminator ";" (hex 3b)
SQL> select * from dual
2 ;
D
-
X
--打开后默认以";"来结尾
SQL> set sqlterminator !
SQL> show sqlterminator
sqlterminator "!" (hex 21)
SQL> select * from dual !
D
-
X
--设置其他字符作为sqlterminator
SQL> set sqlterminator on
SQL> show sqlterminator
sqlterminator ";" (hex 3b)
--设置on之后,依旧改为默认结束代码";"
SQL> set sqlterminator OFF
SQL> update T1
2 set A =
3 'DECLARE
4 RID NUMBER := 0 ;
5 BEGIN
6 SELECT 1 INTO RID
7 FROM dual;
8 END ;'
9 where B= 'xxxx'
10 /
1 row updated.
SQL> commit
2 /
Commit complete.
SQL> set sqlterminator ON
--应用(插入带";"的字符串)
escape
SQLPLUS的escape参数后面可以跟4个东西,分别是ON、OFF、character和"\"
SQL> SET ESC[APE] {\| c|ON|OFF}
Defines the character you enter as the escape character. OFF undefinesthe escape character. ON enables the escape character. ON changes thevalue of c back to the default "\".
简单举例:
SQL> set escape on
SQL> show escape
escape "\" (hex 5c)
SQL> select '\' from dual;
'
-
SQL> select '\\' from dual;
'
-
\
SQL> select '\\\' from dual;
'
-
\
SQL> select '\\\\' from dual;
'\
--
\\
--"\"为转义符,转移任意一个它后面的字符
SQL> set escape !
SQL> select '\\' from dual;
'\
--
\\
SQL> select '!\' from dual;
'
-
\
--使用其他字符作为转义
注意:这里的escape参数与SQL中的escape函数完全不同
-The End-