• 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

  • 相关阅读:
    MVVM教程[资源+分析]
    WPF 多点触摸开发[1]:Windows 7 安装多点触屏模拟器
    wpf 打印 之PirintVisual
    WPF:PrintVisual的问题
    几个漂亮的Button的CSS
    很不错的后台界面收集[提供下载]
    网页刷新方法集合
    JS各种各样的拖动效果
    CSS+DIV(盒子)
    网页刷新方法集合
  • 原文地址:https://www.cnblogs.com/zhaoyangjian724/p/6200204.html
Copyright © 2020-2023  润新知