Jump to content
Max Castril

MySQL change column

Recommended Posts

Hi there

I am using MySQL in "phpmyadmin.eu.ionos.host" and want to change a column to 'UNIQUE' as I don't want to accidentally fill the table with repeat data using an erroneous php loop and each image must be unique.

The table is:  

2        Image           char(200)            utf8_unicode_ci         

SQL won't let me change the column to 'UNIQUE' as it says that there is a duplicate column 'Image'.  The phpmyadmin SQL seems to be trying to add another column, which is what I dont want.

1and1 have very recently changed their software and there seem to be a lot of gremlins in it.  Any comments??

 

Regards

Max 

 

Share this post


Link to post
Share on other sites

Hello,
If you already have duplicate values in the particular column then it will not allow you to put unique constraint into the table.
Otherwise, it will be changed through the following query.

ALTER TABLE table_name ADD CONSTRAINT constraint_name UNIQUE('column_name');

 

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...