Error MySQL 1264: valor fuera de rango para columna


Como I SET cust_fax en una tabla en MySQL como esta:

cust_fax integer(10) NOT NULL,

Y luego inserto un valor como este:

INSERT INTO database values ('3172978990');

Pero luego dice

'error 1264' fuera del valor de la columna

Y quiero saber dónde está el error? Mi set? ¿U otro?

Cualquier respuesta será apreciada!

Author: HerrSerker, 2013-01-11

4 answers

El entero 3172978990 es mayor que 2147483647, de ahí el error**.

Para corregir el error, cambie su tipo de datos a VARCHAR. Teléfono, Fax, etc. debe almacenarse como cadenas. Ver esta discusión.

** Aquí hay un gráfico que le dice qué tipo entero puede almacenar qué valores.

 58
Author: Salman A,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-05-23 11:47:25

Está excediendo la longitud del tipo de datos int. Puede usar el atributo UNSIGNED para admitir ese valor.

SIGNED INT puede soportar hasta 2147483647 y con UNSIGNED INT permite el doble que este. Después de esto, todavía desea guardar datos que use CHAR o VARCHAR con longitud 10

 10
Author: Saharsh Shah,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-01-11 18:47:39

También puede cambiar el tipo de datos a bigInt y resolverá su problema, no es una buena práctica mantener enteros como cadenas a menos que sea necesario. :)

ALTER TABLE T_PERSON MODIFY mobile_no BIGINT;
 8
Author: Rohit Kolhekar,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-06-04 16:56:55

Use sin signo. int = de -2 147 483 648 a 2 147 483 647

 1
Author: soft87,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-01-06 19:12:00