zoukankan      html  css  js  c++  java
  • mysql null值问题

    mysql>   create table test( sn int,
        ->   `createdTime` datetime NOT NULL COMMENT '创建时间',
        ->   `updatedTime` datetime DEFAULT NULL);
    ERROR 2006 (HY000): MySQL server has gone away
    No connection. Trying to reconnect...
    Connection id:    1199508
    Current database: devops
    
    Query OK, 0 rows affected (0.04 sec)
    
    mysql> desc test;
    +-------------+----------+------+-----+---------+-------+
    | Field       | Type     | Null | Key | Default | Extra |
    +-------------+----------+------+-----+---------+-------+
    | sn          | int(11)  | YES  |     | NULL    |       |
    | createdTime | datetime | NO   |     | NULL    |       |
    | updatedTime | datetime | YES  |     | NULL    |       |
    +-------------+----------+------+-----+---------+-------+
    3 rows in set (0.00 sec)
    
    mysql> insert into test values('1',null,null);
    ERROR 1048 (23000): Column 'createdTime' cannot be null
    
    
    mysql> insert into test values('1','2015-01-01 00:00:00',null);
    Query OK, 1 row affected (0.00 sec)
    
    mysql> select * from test;
    +------+---------------------+-------------+
    | sn   | createdTime         | updatedTime |
    +------+---------------------+-------------+
    |    1 | 2015-01-01 00:00:00 | NULL        |
    +------+---------------------+-------------+
    1 row in set (0.00 sec)
    
    
    
    mysql> alter table `test` modify column `updatedTime` datetime NOT NULL COMMENT '更新时间';
    ERROR 1138 (22004): Invalid use of NULL value

  • 相关阅读:
    利用CWinThread实现跨线程父子MFC窗口
    GetForgroundWindow函数的不确定性——BUG笔记
    DLL动态链接库的创建
    php正则讲解 及与 js的正则比较
    cookie和session的讲解
    两种排序的方法 冒泡法 插入法 封装版
    php中获取当前时间
    文件下载及header方法介绍
    文件上传
    二分法封装版
  • 原文地址:https://www.cnblogs.com/zhaoyangjian724/p/6200204.html
Copyright © 2011-2022 走看看