ITPub博客

首页 > Linux操作系统 > Linux操作系统 > null与substr

null与substr

原创 Linux操作系统 作者:wisdomone1 时间:2013-01-22 16:57:52 0 删除 编辑
C:\Users\123>sqlplus scott/system
SQL*Plus: Release 11.2.0.1.0 Production on Tue Jan 22 16:53:44 2013
Copyright (c) 1982, 2010, Oracle.  All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> create table t_substr(a varchar2(10));
Table created.
SQL> insert into t_substr values(null);
1 row created.
SQL> insert into t_substr values('zxy');
1 row created.
SQL> commit;
Commit complete.
SQL> select * from t_substr;
A
--------------------
zxy
 
SQL> select substr(a,1,2) from t_substr;
SUBSTR(A,1,2)
----------------
zx
 
SQL> select substr(null,1,2) from dual;

S
-
SQL> select substr(null,1,2) from t_substr;

S
-
 
 
小结:
          1,如变量值为null,substr运行不会报错,可以正常处理
 
 

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/9240380/viewspace-753051/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
提供针对oracle初学者及进阶的数据库培训,欢迎大家咨询: 微信: wisdomone 微信公众号: lovedb 工作经历: 中国普天 北京科蓝 北京云和恩墨 北京神州新桥

注册时间:2008-04-04

  • 博文量
    2189
  • 访问量
    12690058