Hace un tiempo descubrí una característica (tal vez sea un bug) sobre los campos timestamp de MySQL. Es probable que este documentado en alguna parte que todavía no he leído:
Cuando se añade un campo timestamp a una tabla, MySQL agrega mágicamente algunas características al nuevo campo creado como un «trigger» y la fecha actual como valor por defecto.
Aquí esta el script donde se produce el caso:
-- CREANDO UNA TABLA CUALQUIERA E INSERTANDO DATOS mysql> create table t( -> id int not null primary key auto_increment, -> val varchar(50) -> ); Query OK, 0 rows affected (0.15 sec) mysql> insert into t (val) values ("foo") ,("var"); Query OK, 2 rows affected (0.08 sec) Records: 2 Duplicates: 0 Warnings: 0 mysql> select * from t; +----+------+ | id | val | +----+------+ | 1 | foo | | 2 | var | +----+------+ 2 rows in set (0.00 sec) -- AGREGANDO UN CAMPO TIMESTAMP Y MAS DATOS mysql> alter …[Lea más]