I have a small script in which I want to insert a new column into a table in the database.
This is the content of the file myscript_ddl.sql
:
START TRANSACTION;
ALTER TABLE e1qxp_productos ADD COLUMN 'cierre_venta' TINYINT(4) NULL DEFAULT NULL;
COMMIT;
And to execute it I do it by command line in the following way:
mysql -u usuario -pclave nombrebasededatos < myscript_ddl.sql
It throws me the following error and it will not let me add the field:
ERROR 1067 (42000) at line 2: Invalid default value for 'start_date'
I've tried it manually from PhpMyadmin and the exact same thing happens, the same error. It also refers to fecha_inicio
which is another column of the database that should have nothing to do with the new entry.
Why is it? How can I solve it?
Edit: I add the definition of the table
CREATE TABLE 'e1qxp_productos' (
'id' int(11) UNSIGNED NOT NULL,
'state' tinyint(1) NOT NULL,
'nombre' varchar(255) NOT NULL,
'apellidos' varchar(255) NOT NULL,
'nif_cif' char(9) NOT NULL,
'direccion' varchar(100) NOT NULL,
'ciudad' varchar(100) NOT NULL,
'provincia' varchar(100) NOT NULL,
'cp' varchar(100) NOT NULL,
'tipo_cliente' enum('persona','empresa') DEFAULT 'persona',
'tipo_producto' tinyint(1) DEFAULT '-1',
'fecha_inicio' timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
'fecha_fin' timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
'precio' float DEFAULT NULL,
'marca' varchar(255) DEFAULT NULL,
'enviado' tinyint(1) NOT NULL DEFAULT '0',
'process' varchar(100) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- Indices de la tabla 'e1qxp_productos'
--
ALTER TABLE 'e1qxp_productos'
ADD PRIMARY KEY ('id');