Jump to content
WesleyA

help required with creating a dropped column

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 ?

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...