ERROR 1264: 1264: Out of range value for column 'Cpf' at Row 1 SQL Statement

Asked

Viewed 3,754 times

1

I have a problem in Mysql, I created the following table:

create table pessoas (
cpf int (11),
nome varchar(30) not null,
nascimento date,
endereco varchar(30) not null,
cep int(7),
bairro varchar(20),
cidade varchar(30),
uf char (2),
primary key(cpf)
)default charset = utf8;

I added a column:

alter table pessoas
add column ultima_compra date;

I tried to do the following Insert:

insert into pessoas values
('04496332780', 'João da Silva', '25-11-1969', 'Rua Antônio Numes', '88045963', 'Palmeiras','Londrina', 'PR');

And made that mistake:

ERROR 1264: 1264: Out of range value for column 'Cpf' at Row 1 SQL Statement:**

1 answer

-3

Your mistake was creating columns as Int and trying to write varchar. Try removing quotes from Cpf and cep:

insert into pessoas values (04496332780, 'João da Silva', '25-11-1969', 'Rua Antônio Numes', 88045963, 'Palmeiras','Londrina', 'PR');

*Editing (I didn’t really notice that it exceeded 10 digits): int accepts up to 10 digits. Create table using the correct type:

bigint: -9.223.372.036.854.775.808 à 9.223.372.036.854.775.807
int:    -2.147.483.648 a 2.147.483.647
smallint    -32,768 a 32,767
  • 1

    Even with the quotes the bank would attempt to do the conversion implicitly to the due type. The problem is the ability of the numeric type as @rray already signaled.

  • 2

    But the correct type for CPF is not numerical!

  • I am not here to say what he should or should not do. That was not his question. His question was what that mistake would be. And I believe you answered.

  • I figured out this bug what it was, the size of the cep field was the smallest size. I changed the size but now I’m having another problem.

  • What would that be? Post the mistake here

Browser other questions tagged

You are not signed in. Login or sign up in order to post.