Mysql database setting table field unique

Problem description : For the data table in the MySQL database, it is necessary to require that a certain field cannot be repeated, that is, it must exist uniquely. And it cannot affect the primary key in the table (a table can only have one primary key).

Solution :

ALTER TABLE 表名 ADD unique(`表中的字段`);

//注意这里的表字段所用符号为tab键上边的``,不是引号‘’

Guess you like

Origin blog.csdn.net/fish332/article/details/110653708