Chart a course table was built before me, I set up course_name is unique, and don't be careful to delete course_name field today, and now want to build back course_name this field, and as the candidate key, but appear a mistake, and what is the matter? Thank you for your answer!!!!!!!!!!
CodePudding user response:
You see this error message, course_name repeated, see if you currently don't have this field in the table, see if indexes have this field, you try to create the index to delete againCodePudding user response:
Because course_name is a new field, so this time record of this column is NULLWhen you add set course_name as Not Null, and for the Unique
The database can meet the conditions you set
CodePudding user response:
Because course_name is a new field, this time all the records of this column is NULLWhen you add set course_name as Not Null, and for the Unique
The database can meet the conditions you set
CodePudding user response:
There are two methods, the first: the first rows to delete only one row, in the use of your SQL to create, second: don't use your SQL to create, to create the first field, adding unique value to the field, to create a unique index,Error because of the new column defines a unique index, but do you have more than two lines of table records, so your new column in the case of no value (the new column empty value generally is NULL or the empty string), there are two or more repeated, result in unable to create a unique index