Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MariaDB CURRENT_TIMESTAMP default

I'm trying to set up a DB for user registration and in want to have a column with the registration date in it, which should be the current time by default. I tried running this query:

CREATE TABLE `users` (
  <some stuff>
  `uRegDate` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP
)

But it doesn't work with MariaDB. Anyone got a solution?

like image 539
Curunir Avatar asked Nov 29 '16 11:11

Curunir


1 Answers

What if you change the datatype to TIMESTAMP instead of DATETIME like

`uRegDate` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
like image 91
Rahul Avatar answered Oct 20 '22 01:10

Rahul