Jump to content

MySQL change column


Max Castril

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 

 

Link to comment
Share on other sites

  • 5 months later...

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');

 

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