• 空值的日期类型和update 中的null


    创建一个表

    create table testdate1(name nvarchar(50),dtime datetime)
    go
    insert into testdate1 values('x11',''),('x12','1900-01-01 00:00:00.000')
    go
    select * from testdate1

    image

    select * from testdate1 
    where dtime=''

    image

    update testdate1 set dtime=null
    where name='x11'
    select * from testdate1
    where dtime is null

    image

    上面的测试,只是要说明两点

    1.datetime类型是空的话,会设置为datetime的初始值;select查询时where条件直接可以=’’。这条很容易理解的

    2.update语句中,null值也使用'=’;以前只知道where条件中的null,必须使用is null(当然SET ANSI_NULLS ON改为OFF就可以用‘=’,一般人不会闲着蛋疼加上这句,我刚刚蛋疼了一把),而不知道更新中可以使用‘=’设置null

  • 相关阅读:
    监听
    用户管理
    oracle网络
    实例 参数
    存储管理
    oracle 体系
    实例
    修改
    集合操作
    17.08.18
  • 原文地址:https://www.cnblogs.com/cnmarkao/p/3835726.html
Copyright © 2020-2023  润新知