My user table has previously string primary key now i added a new field userid bigint(20) and made this primary key.
then added
ALTER TABLE smsusers AUTO_INCREMENT = 2335;
Total records in user table are 2334 next record should take value 2335 and should be auto incremented as records are added.
Problem is while inserting data from my application it is showing following error
SQLException java.sql.SQLException: Field 'userid' doesn't have a default value
How to resolve this problem
EDIT: while trying to insert new data
INSERT INTO `dbname`.`smsusers` ( `password`, `fname`, `lname`,
`mailid`, `dob`, `gender`) VALUES ('asdf', 'asdf', 'asdf',
'[email protected]', '2013-10-10', 'm');
It is showing following error
#1062 - Duplicate entry '0' for key 1
EDIT: Initially my primary key was id than i added userid and made this primary key
MY table structure is
CREATE TABLE `smsusers` (
`id` varchar(60) NOT NULL DEFAULT '',
`password` varchar(50) NOT NULL,
`fname` varchar(30) NOT NULL,
`lname` varchar(30) DEFAULT NULL,
`mailid` varchar(50) NOT NULL,
`dob` date NOT NULL,
`gender` varchar(10) NOT NULL,
`city` varchar(70) DEFAULT NULL,
`userid` int(20) NOT NULL DEFAULT '0',
PRIMARY KEY (`userid`),
KEY `id_pk_unique` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
While inserting data in smsusers it it only taking default value at 0 not the incremented value.