Question

I'm running Percona's fork of mysql (5.6.15) on Ubuntu 13.04. After spending far too long trying to debug a problem with one of our ETL processes, I discovered mysql was modifying my create table syntax:

mysql> CREATE TABLE test ( test TIMESTAMP );
Query OK, 0 rows affected (0.03 sec)

mysql> show create table test\G
*************************** 1. row ***************************
       Table: test
Create Table: CREATE TABLE `test` (
  `test` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=latin1
1 row in set (0.01 sec)

mysql>

I don't want this on update trigger, I've discovered I can get around this by making the column a 'TIMESTAMP NULL' instead, but I also don't want this field to be nullable.

Am I totally off base or should this not be happening? Has anyone encountered this before? Is this some setting I'm not aware of or could this be a bug (I know they changed some behaviour of timestamp fields in 5.6)?

Was it helpful?

Solution

It's not a bug, it's just that the first timestamp column in a table (if not specified otherwise) gets these attributes. Would you add another timestamp column, it would not get those attributes. Read more about it in the manual. If you really really have a problem with it, maybe a datetime instead of timestamp column would be an option?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top