Man liest oft:
|
1 |
ALTER TABLE foo ALTER COLUMN bar SET DEFAULT CURRENT_TIMESTAMP; |
was aber nicht funktioniert. Stattdessen geht (und: ja, die Spalte wird zwei mal aufgeführt #wtf):
|
1 |
ALTER TABLE foo CHANGE bar bar TIMESTAMP DEFAULT CURRENT_TIMESTAMP; |
, führt aber ggf. zu einem Fehler, wenn man bereits eine “ON UPDATE CURRENT_TIMESTAMP”-Spalte hat:
Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause
Das ist eine dokumentierte Begrenzung in SQL < v5.6:
Previously, at most one
TIMESTAMPcolumn per table could be automatically initialized or updated to the current date and time. This restriction has been lifted. AnyTIMESTAMPcolumn definition can have any combination ofDEFAULT CURRENT_TIMESTAMPandON UPDATE CURRENT_TIMESTAMPclauses.
Ihr müsstet eines der beiden Daten dann manuell setzen m(