• 请不要在回答技术问题时复制粘贴 AI 生成的内容
cway
V2EX  ›  程序员

疑问? Oracle 中 IS NOT NULL 与<>''有区别么?

  •  
  •   cway · Mar 2, 2020 · 3669 views
    This topic created in 2437 days ago, the information mentioned may be changed or developed.

    情景再现,oracle 数据库表中有某条数据字段值为 null

    我将此字段用<>''与 IS NOT NULL 都筛选能查询到该条数据

    是不是说明这两种写法都能进行非空判断??

    再加上前端时间好像看过一篇文章说 is not null 影响索引,那我直接用<>''代替可以么? 求解

    5 replies  •  2020-03-02 15:24:51 +08:00
    tinkerer
    tinkerer
    Mar 2, 2020
    1
    - 不等于 ''
    - 不是 NULL
    LeeLou
    LeeLou
    Mar 2, 2020
    3
    ''可以='', 而 NULL 不等于另一个 NULL,

    is not null 影响索引,那么<>''也是影响索引的。
    passerbytiny
    passerbytiny
    Mar 2, 2020
    4
    你的抽样数据不足造成的。你造一下数据,列的值依次是 ['a',null,''] ,再用那两个条件查询一下看看,应该有惊喜的。
    qqq8724
    qqq8724
    Mar 2, 2020
    5
    oracle 中 '' 好像是会自动转成 null
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2900 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 14:01 · PVG 22:01 · LAX 06:01 · JFK 09:01
    ♥ Do have faith in what you're doing.