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);
CodePudding user response:
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));