WesleyA Posted November 3, 2015 Share Posted November 3, 2015 I dropped a column (linknum) in a table (wine) with mysql in the console After that I wanted to make it again ALTER TABLE wine ADD linknum INT DEFAULT '1' NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST; but now I recieve an error message like this: ERROR 1067 (42000): Invalid default value for 'linknum' How can I solve it, and create a column called linknum again, starting with 1 and incrementing 1 ? Link to comment Share on other sites More sharing options...
dsonesuk Posted November 3, 2015 Share Posted November 3, 2015 Since it uses auto increment and primary key, i very much doubt it will allow default, or multiple default values to be allowed. Link to comment Share on other sites More sharing options...
Ingolme Posted November 3, 2015 Share Posted November 3, 2015 In the CREATE statement, add AUTO_INCREMENT=1 at the end of it. CREATE TABLE `table_name` ( fields)AUTO_INCREMENT=1 On a side note, since the field was an integer field, it shouldn't have been DEFAULT '1', but DEFAULT 1. Wrapping the number in quotes tells MySQL that it's text type data. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now