I want a non-nullable timestamp
column where the inserter is required to specify what the value should be.
The following configuration
CREATE TABLE test (
t timestamp not null
);
results in the default CURRENT_TIMESTAMP
value, while
CREATE TABLE test (
t timestamp not null default null
);
results in
ERROR 1067 (42000): Invalid default value for 't'
I want the same behavior that, for example, the int
column below has:
CREATE TABLE test (
i int not null
);
Best Answer
I think that the only way is setting the server variable
explicit_defaults_for_timestamp
toON
(default isOFF
).This will disable the non-standard behaviour of
timestamp
columns regardingNULL
values: