zoukankan      html  css  js  c++  java
  • 空值的日期类型和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

  • 相关阅读:
    css边框以及其他常用样式
    jemeter学习-badboy录制与代理服务器录制
    linux基础命令学习
    cookie与session
    网址保存
    安全性测试要点转摘
    Charles弱网测试转载
    java 中文乱码以及转码
    spring学习总结——高级装配学习四(运行时:值注入、spring表达式)
    spring学习总结——高级装配学习三(Bean的作用域)
  • 原文地址:https://www.cnblogs.com/cnmarkao/p/3835726.html
Copyright © 2011-2022 走看看