Using UPDATE CURRENT_TIMESTAMP
is it possible to automatically update a field from a table in the MySQL database?
I want the inclusion date to be included in the fields: dt_cadastro
and dt_atualizacao
.
And when a change is made, the dt_atualizacao
field is updated with the change date.
Follow my table:
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;