MySQL primary key constraints and uniqueness constraints
MySQL primary key constraints and uniqueness constraints are both indexes. The differences between them are:
- The primary key field can be unique, but the primary key field cannot be NULL.
- The Uniqueness constraint ensures uniqueness, but the field of the uniqueness constraint can be NULL.
- The Uniqueness constraint does not apply to records with NULL values. That is, records with NULL values can be added repeatedly. The primary key field cannot be NULL.
Mysql-workbench cannot create multi-field uniqueness constraints. You can manually add them on the command line.
Added multi-field uniqueness constraints
Mysql> alter table pai_end_regexp add constraint dev_series_uniq UNIQUE (dev_category_id, dev_series_id, dev_type_id );
Delete uniqueness Constraint
Mysql> alter table pai_end_regexp drop index dev_series_uniq;
The following content may also help you:
Install MySQL 5.6.24 in CentOS 6.6
Install MySQL 5.6.23 in Linux
The following is the MySQL-related content carefully selected by the editor to see if it is helpful:
Install MySQL 5.6 with the source code in CentOS 7
How to install and configure MySQL5.7.3.0
Install MySQL in Ubuntu 14.04
MySQL authoritative guide (original book version 2nd) Clear Chinese scan PDF
Ubuntu 14.04 LTS install LNMP Nginx \ PHP5 (PHP-FPM) \ MySQL
Build a MySQL Master/Slave server in Ubuntu 14.04
Build a highly available distributed MySQL cluster using Ubuntu 12.04 LTS
Install MySQL5.6 and Python-MySQLdb in the source code of Ubuntu 12.04
MySQL-5.5.38 universal binary Installation
This article permanently updates the link address: