Pregunta

No puedo encontrar cómo se ve la sintaxis para agregar una columna de fecha y hora a una tabla MySQL cuando quiero establecer el predeterminado en - Ejemplo - 2011-01-26 14:30:00

¿Alguien sabe cómo se ve esa sintaxis?

Esto es lo que tengo

ADD COLUMN new_date DATETIME AFTER preceding_col,

Gracias

¿Fue útil?

Solución

Si alguna vez tiene dudas, la sintaxis se explica aquíhttp://dev.mysql.com/doc/refman/5.5/en/alter-table.html

ALTER TABLE yourTable 
  ADD COLUMN new_date DATETIME NOT NULL DEFAULT 20110126143000 AFTER preceding_col

o

ALTER TABLE yourTable 
  ADD COLUMN new_date DATETIME NOT NULL DEFAULT '2011-01-26 14:30:00' AFTER preceding_col

(Solo prefiero el formato numérico de fecha y hora)

Otros consejos

ALTER TABLE  `yourTable`
ADD `new_date` DATETIME NOT NULL
DEFAULT '2011-01-26 14:30:00'
AFTER `preceding_col`
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top