当前位置:网站首页>Oracle中对空字符串的判断
Oracle中对空字符串的判断
2022-07-21 08:19:00 【大宇进阶之路】
oracle中常见的一个小错误就是字符串判断是否为空。
习惯了编程的人喜欢用<> !=,但这样都是错误的,应该使用is null 或者 is not null, 或者使用nvl函数
首先理解,在oracle中,默认将空字符视为null,而对null进行判断都为false
例如: ‘1’ != null 我们看上去这是对的,但是和null的比较都为fasle,所以结果是false
举个例子:
select ( case when 'sdfds' is not null then 1 else 2 end ) result from dual;
select ( case when 'sdfds' !=null then 1 else 2 end ) result from dual;
或者使用nvl函数,nvl(字符串,为空时的默认值)
边栏推荐
猜你喜欢
The Linux server installed the graphical interface, but failed to display the initialization graphical interface when installing the database
【着色器实现Television信号三原色闪烁效果_Shader效果第五篇】
Advanced C language: data storage (deep analysis - integer)
Reprint: can bus terminal resistance
动态规矩-数组压缩优化
[paper reading] deep video analog detection: opportunities and challenges
OSPF知识总结
阿里面试应该注意什么?通过5轮面试的阿里实习生亲述
tinymce 去掉编辑器换行默认增加的p标签
SpaceX has reached an agreement with Mattel, a Barbie doll manufacturer, on theme toy products
随机推荐
OSPF knowledge summary
swift 【block】
SSM integrates other components
Dynamic programming knapsack problem -- 01 knapsack
慧荣科技与江波龙协同提升手机存储竞争力
Mysql03 (Association query)
The Linux server installed the graphical interface, but failed to display the initialization graphical interface when installing the database
【集训DAY9】Rotato【暴力】【思维】
Major breakthrough! Successful development of the first domestic scientific computing software
MySQL 5.7 configuration replication
Screen sharing software --deskreen
乘风破浪,金融科技时代下的数字化转型之路
C language: leak detection and filling (I)
Mysql08 (transaction)
EasyExcel实现文件上传-批量插入 文件下载
c语言:查漏补缺(一)
Riding the wind and waves, the road of digital transformation in the era of financial technology
Rust learning notes -rust language foundation
【集训DAY6】Game【数学】
新知识经济时代,谁在生产知识?