Nouvelle table :
CREATE TABLE `users` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`email` varchar(100) NOT NULL,
`firstname` varchar(30) NOT NULL,
`lastname` varchar(50) NOT NULL,
`password` char(32) NOT NULL,
`created_at` datetime NOT NULL DEFAULT current_timestamp(),
`updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(),
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
Table existante (avec les colonnes existantes) :
ALTER TABLE users
MODIFY COLUMN `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
MODIFY COLUMN `updated_at` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP;