Oracle 與 Mysql NULL值,空字符串''的區別


Oracle(null等同於空字符'')

1.oracle插入空字符串默認替換成null

2.oracle查詢(null和被替換的空字符)時使用 is null/is not null

3.使用聚合函數時自動忽略null值

Mysql(null不等同於空字符'')

1.mysql插入null顯示為null,插入空字符串顯示空

2.null查詢用 is null/is not null,空字符''查詢用 =''/<>''

3.使用聚合函數時自動忽略null值

 

mapping.xml:

<if test='desc1!=null '>
    <choose>
        <when test='desc1!="" '>
            and A.DESC1 = #{desc1}
        </when>
        <otherwise>
            and (A.DESC1 is null or A.DESC1 = '')
        </otherwise>
    </choose>
</if>

java邏輯:

if desc1 !=null{
  switch(s):
        case desc1!="":and A.DESC1 = #{desc1}
        default:A.DESC1 is null or A.DESC1 = ''
}else{

}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM