I'd like to add a constraint on a mySQL table for the default value of a datetime column, just like here, but the command solving the issue just doesn't work for me.
I created my table with :
create table `transactions`
( `id` int NOT NULL AUTO_INCREMENT,
`timeTransaction` DATETIME,
`montant` int,
`donneur` varchar(50),
`receveur` varchar(200),
primary key(`id`));
and when I try
ALTER TABLE transactions ADD CONSTRAINT DF_TIME_TRANS DEFAULT GETDATE() FOR timeTransactions;
It always return a syntax error on the DEFAULT :
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT GETDATE() FOR timeTransactions' at line 1
I tried defining the constraint during the creation of the table but I still got stuck on the DEFAULT. Any idea why this is happening ?