Reputation: 8277
I created a table now I want to add date time column but I want to current date time of each row insertion.
I have written syntax like this:
ALTER TABLE particle_photon ADD COLUMN dt_created NOT NULL default CURRENT_TIMESTAMP AFTER humidity;
but I get error:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'NOT NULL default CURRENT_TIMESTAMP AFTER humidity' at line 1
Upvotes: 0
Views: 890
Reputation: 222492
You are missing the declaration of the datatype (I assume TIMESTAMP
):
ALTER TABLE particle_photon
ADD COLUMN dt_created TIMESTAMP
NOT NULL DEFAULT CURRENT_TIMESTAMP AFTER humidity;
CREATE TABLE particle_photon(id INT PRIMARY KEY, humidity INT, lastcol INT);
ALTER TABLE particle_photon
ADD COLUMN dt_created TIMESTAMP
NOT NULL DEFAULT CURRENT_TIMESTAMP AFTER humidity;
Upvotes: 1