Re: Can't create NOT NULL timestamp
If I'm not mistaken, a TIMESTAMP attribute is automatically NOT NULL and you have use the NULL keyword to override that. At least if it's the first TIMESTAMP attribute in the file. As you can see below, the "Null" column (sorry for the formatting) is NO for both attributes and the "Default" is CURRENT_TIMESTAMP on the startTime attribute. This should do what you're looking for.
mysql> CREATE TABLE sample1 (
-> id int(10) UNSIGNED PRIMARY KEY AUTO_INCREMENT,
-> startTime TIMESTAMP
-> );
Query OK, 0 rows affected (0.08 sec)
mysql> show columns from sample1;
+-----------+
| Field | Type | Null | Key | Default | Extra
+-----------+
| id | int(10) unsigned | NO | PRI | NULL | auto_increment
| startTime | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP
+-----------+
2 rows in set (0.01 sec)
mysql>
Subject
Written By
Posted
September 02, 2015 10:53AM
Re: Can't create NOT NULL timestamp
September 03, 2015 04:53PM
September 03, 2015 05:40PM
September 04, 2015 04:03AM
September 04, 2015 04:12AM
September 05, 2015 02:53PM
September 05, 2015 06:22PM
September 05, 2015 07:33PM
September 05, 2015 08:21PM
September 06, 2015 01:37AM
September 06, 2015 01:43AM
September 06, 2015 02:16AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.