Configure the data_lancamento
for the guy TIMESTAMP, and put in value Default CURRENT_TIMESTAMP.
Creation of Example Table:
CREATE TABLE `testdb`.`Exemplo` (
`id` INT NOT NULL AUTO_INCREMENT ,
`data_lancamento` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ,
PRIMARY KEY (`id`)
);
This solution is automatic by the bank itself, but if you do not want to change and maintain the datetime
or date
just put a now()
in your SQL so:
INSERT INTO exemplo (data_lancamento) values (now());
You can also create a Trigger
CREATE TRIGGER `exemplotrigger` BEFORE INSERT ON `exemplo`
FOR EACH ROW SET NEW.data_lancamento = NOW();
Note: To Date
or DateTime
there is not the same resource of type TIMESTAMP
.
References:
that’s right, thanks bro ;)
– Silvio Andorinha