Decode360's Blog

业精于勤而荒于嬉 QQ:150355677 MSN:decode360@hotmail.com

  BlogJava :: 首页 :: 新随笔 :: 联系 ::  :: 管理 ::
  397 随笔 :: 33 文章 :: 29 评论 :: 0 Trackbacks
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函数完全不同
 
 
 
posted on 2009-03-30 21:54 decode360 阅读(289) 评论(0)  编辑  收藏 所属分类: 05.SQL

只有注册用户登录后才能发表评论。


网站导航: