0
Using the UPDATE CURRENT_TIMESTAMP
it is possible to automatically update a field from a table in the Mysql database?
I want the inclusion date to be assigned to the fields: dt_cadastro
and dt_atualizacao
.
And when a change is made, the field dt_atualizacao
is updated with the modification date.
Follow my schedule:
DROP TABLE IF EXISTS `tbl_devedor`;
CREATE TABLE IF NOT EXISTS `tbl_devedor` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`nome` varchar(255) NOT NULL,
`sistema` varchar(5) NOT NULL,
`id_assessoria` INT(11) NOT NULL,
`dt_cadastro` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`dt_atualizacao` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`situacao` TINYINT(1) NULL DEFAULT NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB
DEFAULT CHARSET = utf8;
creates a Rigger to fire
update tbl_devedor set dt_atualizacao = current_timestamp where id = new.id;
– Rovann Linhalis
Is giving some error currently?
– Woss
@Andersoncarloswoss Error does not give, but is not updating.
– Wagner Fillio
What SQL statement did you use to update?
– Woss