I have a table that is as follows:
CREATE TABLE SomeTable (
id int unsigned NOT NULL AUTO_INCREMENT,
status enum('broken','repaired') NOT NULL,
from datetime NOT NULL,
until datetime NOT NULL,
brought_in timestamp,
brought_by varchar(255) NOT NULL,
repair_status enum('unpayed', 'payed') DEFAULT NULL,
payed_when timestamp,
delivered_when timestamp,
primary key(id)
);
When I create the table if I do a SHOW CREATE TABLE
then I see that the column brought_in
is defined to have the current timestamp ON INSERT
and ON UPDATE
.
But I did not add such an instruction in my create table.
Why doesn't it let it be empty like the other columns?
Now on every insert or update of another column it adds the current timestamp. I don't want that.
It does not do that with the other columns. What am I doing wrong?
timestamp
column. Read the documentation: Automatic Initialization and Updating forTIMESTAMP
. If you don't want this, you have to explicitly tell MySQL.brought_in timestamp NULL DEFAULT NULL,
or some otherdefault
value and you'll have no automatic properties.TIMESTAMP
columns are by defaultNOT NULL
while all other columns are by defaultNULL
...