Restrictions on unique constraints of Mysql partition tables

Source: Internet
Author: User

I believe you have some knowledge about Mysql partition tables. The following describes the limitations of Mysql partition tables on unique constraints. If you are interested in this, take a look.

Mysql Partition Table restrictions on Partitioning Keys, Primary Keys, and Unique Keys

In Mysql 5.1, the unique constraints of a partition table are clearly defined. Each unique constraint must contain the partition key of the partition table and the primary key constraint ).
This sentence may not be easy to understand. Let's do a few experiments:

 
 
  1. CREATE TABLE t1     
  2. (      id INT NOT NULL,  
  3.        uid INT NOT NULL,   
  4.        PRIMARY KEY (id)  
  5. )  
  6. PARTITION BY RANGE (id)     
  7. (PARTITION p0 VALUES LESS THAN(5) ENGINE = INNODB,   
  8.  PARTITION p1 VALUES LESS THAN(10) ENGINE = INNODB);   
  9. CREATE TABLE t1     
  10. (      id INT NOT NULL,      
  11.        uid INT NOT NULL,  
  12.        PRIMARY KEY (id)  
  13. )  
  14. PARTITION BY RANGE (id)     
  15. (PARTITION p0 VALUES LESS THAN(5) ENGINE = MyISAM DATA DIRECTORY='/tmp' INDEX DIRECTORY='/tmp',   
  16. PARTITION p1 VALUES LESS THAN(10) ENGINE = MyISAM DATA DIRECTORY='/tmp' INDEX DIRECTORY='/tmp');   
  17.  
  18. mysql> CREATE TABLE t1    
  19.      -> (      id INT NOT NULL,      
  20.      ->        uid INT NOT NULL,   
  21.      ->        PRIMARY KEY (id),  
  22.      ->        UNIQUE KEY (uid)   
  23.      -> )  
  24.      -> PARTITION BY RANGE (id)   
  25.      -> (PARTITION p0 VALUES LESS THAN(5),  
  26.      ->  PARTITION p1 VALUES LESS THAN(10)   
  27.      -> );ERROR 1503 (HY000): A UNIQUE INDEX must include all columns in the table's partitioning function  
  28.  

In-depth discussion on MySQL Lock Mechanism

Detailed description of MySQL Data Table types

Enumeration in the MySQL Field

Add and delete fields in MySQL

MySQL Field Type

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.