Jump to content

problem with LIST COLUMNS partitioning ("A PRIMARY KEY must include all columns in the table's partitioning function")


phdphd
Go to solution Solved by mikosiko,

Recommended Posts

Hi All, I am trying to partition an existing table with LIST COLUMNS partitioning.

 

The structure of my statement is the following :

alter table table_name
PARTITION BY LIST COLUMNS(field_name) (
    PARTITION p1 VALUES IN('value1'),
    PARTITION p2 VALUES IN(' value2')
)

I get the message "A PRIMARY KEY must include all columns in the table's partitioning function".

 

I do not understand this message. In the example below (successfully tested) taken from http://dev.mysql.com/doc/refman/5.5/en/partitioning-columns-list.htm it does not seem that the city column is a primary key. Actually there seems to be no primary key at all in the table definition.

 

CREATE TABLE customers_1 (
    first_name VARCHAR(25),
    last_name VARCHAR(25),
    street_1 VARCHAR(30),
    street_2 VARCHAR(30),
    city VARCHAR(15),
    renewal DATE
)
PARTITION BY LIST COLUMNS(city) (
    PARTITION pRegion_1 VALUES IN('Oskarshamn', 'Högsby', 'Mönsterås'),
    PARTITION pRegion_2 VALUES IN('Vimmerby', 'Hultsfred', 'Västervik'),
    PARTITION pRegion_3 VALUES IN('Nässjö', 'Eksjö', 'Vetlanda'),
    PARTITION pRegion_4 VALUES IN('Uppvidinge', 'Alvesta', 'Växjo')
);

There must be something I did not grasp. Thanks for helping.

 

Link to comment
Share on other sites

OK. From the example taken from  http://dev.mysql.com I sucessfully added an id field then created a pk spanning both fields (id+city). I then run

SHOW CREATE TABLE `customers_1` 

and got

CREATE TABLE `customers_1` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `first_name` varchar(25) DEFAULT NULL,
 `last_name` varchar(25) DEFAULT NULL,
 `street_1` varchar(30) DEFAULT NULL,
 `street_2` varchar(30) DEFAULT NULL,
 `city` varchar(15) NOT NULL DEFAULT '',
 `renewal` date DEFAULT NULL,
 PRIMARY KEY (`id`,`city`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1
/*!50500 PARTITION BY LIST  COLUMNS(city)
(PARTITION pRegion_1 VALUES IN ('Oskarshamn','Högsby','Mönsterås') ENGINE = InnoDB,
PARTITION pRegion_2 VALUES IN ('Vimmerby','Hultsfred','Västervik') ENGINE = InnoDB,
PARTITION pRegion_3 VALUES IN ('Nässjö','Eksjö','Vetlanda') ENGINE = InnoDB,
PARTITION pRegion_4 VALUES IN ('Uppvidinge','Alvesta','Växjo') ENGINE = InnoDB) */

What does "50500" stand for ?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.