Max Castril Posted November 11, 2018 Share Posted November 11, 2018 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 More sharing options...
dsonesuk Posted November 11, 2018 Share Posted November 11, 2018 ALTER TABLE tablename ADD UNIQUE (Image); Should be enough, where 'tablename' is the name of the table with 'Image' column in it. Link to comment Share on other sites More sharing options...
ishan_shah Posted April 22, 2019 Share Posted April 22, 2019 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 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