MySQL primary key constraints and uniqueness constraints

Source: Internet
Author: User

MySQL primary key constraints and uniqueness constraints

MySQL primary key constraints and uniqueness constraints are both indexes. The differences between them are:

  1. The primary key field can be unique, but the primary key field cannot be NULL.
  2. The Uniqueness constraint ensures uniqueness, but the field of the uniqueness constraint can be NULL.
  3. 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:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.