#1264 - Out of range value for column 'ano' at Row 1

Asked

Viewed 3,043 times

3

Query:

INSERT INTO veiculo(nome,modelo,placa,ano) 
VALUES('teste','testeModel','ASD5647',2012)

Campos:

nome   | varchar
modelo | varchar 
placa  | varchar
ano    | int

Reported error:

#1264 - Out of range value for column 'ano' at Row 1

Why are you making this mistake? How to solve?

  • 1

    Confirm the type of column ano, because it must not be like int, put the DDL of your Tablea veiculo.

1 answer

7

It has nothing to do with "single quotes", columns like int do not need "quotes" in past values

That mistake:

1264 - Out of range value for column

Indicates that the entered value has exceeded the set limit, it is likely that you are not inserting 2012, but a totally different value (or the problem is in the data input) or maybe you used something like DECIMAL(1,1).

You can change the size with ALTER TABLE (if the guy isn’t int):

ALTER TABLE veiculos MODIFY COLUMN ano INT(4);

You can also choose the type DATE or YEAR(4), I don’t know what the advantages will have with the type of date columns, but maybe it is the use of functions for calculations.

Now if the problem is really in the year, the problem is at the origin of the data.

  • 3

    had not read the error well, its answer is correct :D

  • 1

    I believe the problem is with the guy who was put in the field ano. If I’m not mistaken, the value between parentheses is not linked to the amount of characters to be stored.

  • 2

    @Guilhermenascimento you understand, so I asked him to confirm, I only commented that the value placed on INT(X) is not related to the error mentioned, see http://sqlfiddle.com/#! 9/07d273/1.

  • 1

    @Henry is possible even, I had not realized, I reviewed a little, but I really have no way of knowing where the problem occurred.

Browser other questions tagged

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