Pregunta

Estoy tratando la siguiente instrucción SQL:

create table sample (
id int not null primary key auto_increment,
name varchar(100),
date_modified timestamp not null default current_timestamp on update current_timestamp,
date_created timestamp not null default now()
)

No está funcionando ... Estoy recibiendo el siguiente error:

#1293 - Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause

Necesito hacer un seguimiento de dos marcas de fecha, uno para la fecha de la fila se ha creado y uno para la fecha de la fila se modificó por última vez. Ambos hacen lo que quiero yo los utilizo solo, pero MySQL no me permite combinarlas en una sola tabla.

Por favor, ayuda. :)

¿Fue útil?

Solución

Puede crear y modificar BEFORE UPDATE gatillo date_modified en ella.

O BEFORE INSERT y crean date_created allí.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top