"TIMESTAMP" return NULL in table
MySQL 8.0.17
CREATE TABLE towary(
id SERIAL,
nazwa VARCHAR(255),
przyjecie TIMESTAMP
);
INSERT INTO towary (nazwa) VALUES ('AAA');
"TIMESTAMP" return NULL in table
MySQL 8.0.17
CREATE TABLE towary(
id SERIAL,
nazwa VARCHAR(255),
przyjecie TIMESTAMP
);
INSERT INTO towary (nazwa) VALUES ('AAA');
You are inserting a row with three columns. The first has a "default" value because it is serial
, so it gets assigned.
The timestamp
column has no default value, so it is assigned NULL
.
If you want it to default to the current timestamp, you need to assign a default value:
CREATE TABLE towary(
id SERIAL,
nazwa VARCHAR(255),
przyjecie TIMESTAMP DEFAULT current_timestamp
);
Here is a db<>fiddle.