MySQL の TIMESTAMP カラムに null 値を入れる

GAC なぜなにGAC->PHP->フォームからDBへNULL値を挿入 より。


mysql> create table test_1 (
    -> id smallint not null,
    -> time timestamp);
mysql> insert into test_1 values (1, null);
mysql> select * from test_1;
+----+---------------------+
| id | time                |
+----+---------------------+
|  1 | 2006-03-24 00:17:42 |
+----+---------------------+
 
nullを入れると現在時刻になってしまうようです。
 
mysql> create table test_2 (
    -> id smallint not null,
    -> time_1 timestamp null,
    -> time_2 timestamp);
mysql> insert into test_2 values(1,null,null);
mysql> select * from test_2;
+----+--------+---------------------+
| id | time_1 | time_2              |
+----+--------+---------------------+
|  1 |   NULL | 2006-03-24 00:19:20 |
+----+--------+---------------------+
 
nullを明示的に許可するとNULLが入ってくれるみたい。

MySQL AB :: MySQL 4.1 リファレンスマニュアル :: 6.2.2.2 DATETIME、DATE、TIMESTAMP 型 によると、MAXDBというDBMSがあるらしい?
よくわからん……

tags: zlashdot Database MySQL

Posted by NI-Lab. (@nilab)