sql >> Base de Datos >  >> RDS >> Mysql

Error de MySQL Solo puede haber una columna TIMESTAMP con CURRENT_TIMESTAMP en la cláusula DEFAULT aunque no esté haciendo nada malo

Según el manual de MySQL, versión 5.5, Inicialización y actualización automáticas para TIMESTAMP

CREATE TABLE t1 (
  ts TIMESTAMP
);

Sin embargo,

CREATE TABLE t1 (
  ts TIMESTAMP DEFAULT 0
);

Entonces, esto debería funcionar:

CREATE TABLE AlarmHistory
(
    id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    value DOUBLE NOT NULL,
    startedStamp TIMESTAMP DEFAULT 0 NOT NULL,
    finishedStamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL
);

violín