Jump to content

help required with creating a dropped column


WesleyA

Recommended Posts

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...