Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why am I getting #1264 – Out of range value for column 'Identity_no' at row 1?

I create a table and Identity_no is unique in that but I am getting error when I try to add a integer value with 8 number.Probably I am getting this error because I identified unique to Identity_no.How can I fix that
Here is the code for creating table:

CREATE TABLE Members(
    Member_id INTEGER PRIMARY KEY AUTO_INCREMENT NOT NULL,
    Identity_no INTEGER NOT NULL UNIQUE,
    Member_Name varchar(80) NOT NULL,
    Member_Surname varchar(80) NOT NULL,
    Member_Phone CHAR(11),
    MemberCityID INTEGER NOT NULL,
    FOREIGN KEY(MemberCityID) REFERENCES Cities(City_id));

Here is the code for adding data:

INSERT INTO Members 
  (Member_id,Identity_no,Member_Name,Member_Surname,Member_Phone,MemberCityID) 
VALUES
  (1,89768434566,"John","W","05379621522",78);

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The INTEGER type is a 32 bit signed int, which means numbers bigger than 2^31 cannot be stored in a column with this type.
Use BIGINT instead:

CREATE TABLE Members(
Member_id INTEGER PRIMARY KEY AUTO_INCREMENT NOT NULL,
Identity_no BIGINT NOT NULL UNIQUE,
Member_Name varchar(80) NOT NULL,
Member_Surname varchar(80) NOT NULL,
Member_Phone CHAR(11),
MemberCityID INTEGER NOT NULL,
FOREIGN KEY(MemberCityID) REFERENCES Cities(City_id));
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading