HiveBrain v1.2.0
Get Started
← Back to all entries
snippetsqlMinor

how to add removed partition?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
partitionremovedaddhow

Problem

This is the structure of my table:

``
-- Table: t_keyword_conversion_ga
-- Create Table:
CREATE TABLE
t_keyword_conversion_ga (
id int(11) NOT NULL AUTO_INCREMENT,
own_domain_id int(11) DEFAULT NULL,
keyword_id int(11) DEFAULT NULL,
traffic_date date DEFAULT NULL,
targeturl_id int(11) DEFAULT NULL,
entrance int(11) DEFAULT NULL,
transactions int(11) DEFAULT NULL,
item_revenue decimal(9,2) DEFAULT NULL,
goal1completions int(11) DEFAULT NULL,
goal2completions int(11) DEFAULT NULL,
goal3completions int(11) DEFAULT NULL,
goal4completions int(11) DEFAULT NULL,
goal5completions int(11) DEFAULT NULL,
goal6completions int(11) DEFAULT NULL,
goal7completions int(11) DEFAULT NULL,
goal8completions int(11) DEFAULT NULL,
goal9completions int(11) DEFAULT NULL,
goal10completions int(11) DEFAULT NULL,
goal1Value decimal(9,2) DEFAULT NULL,
goal2Value decimal(9,2) DEFAULT NULL,
goal3Value decimal(9,2) DEFAULT NULL,
goal4Value decimal(9,2) DEFAULT NULL,
goal5Value decimal(9,2) DEFAULT NULL,
goal6Value decimal(9,2) DEFAULT NULL,
goal7Value decimal(9,2) DEFAULT NULL,
goal8Value decimal(9,2) DEFAULT NULL,
goal9Value decimal(9,2) DEFAULT NULL,
goal10Value decimal(9,2) DEFAULT NULL,
medium varchar(255) DEFAULT NULL,
source varchar(255) DEFAULT NULL,
KEY
id (id),
KEY
keyword_id (keyword_id),
KEY
traffic_date (traffic_date),
KEY
own_domain_id (own_domain_id,traffic_date),
KEY
targeturl_id (targeturl_id`)
) ENGINE=InnoDB AUTO_INCREMENT=581732054 DEFAULT CHARSET=utf8
/*!50500 PARTITION BY RANGE COLUMNS(traffic_date)
(PARTITION p201101 VALUES LESS THAN ('2011-01-01') ENGINE = InnoDB,
PARTITION p201102 VALUES LESS THAN ('2011-02-01') ENGINE = InnoDB,
PARTITION p201103 VALUES LESS THAN ('2011-03-01') ENGINE = InnoDB,
PARTITION p201104 VALUES LESS THAN ('2011-04-01') ENGINE = InnoDB,
---->PARTITION p201105 VALUES LESS THAN ('2011-05-01') ENGINE = InnoDB,
PARTITION p201106 VALUES LESS THAN ('2011-06-01') ENGINE =

Solution

The following seems to work in Mysql 5.5.

ALTER TABLE t_keyword_conversion_ga REORGANIZE PARTITION p201106 INTO (
PARTITION p201105 VALUES LESS THAN ('2011-05-01') ENGINE = InnoDB,
PARTITION p201106 VALUES LESS THAN ('2011-06-01') ENGINE = InnoDB
);

as you can check by sqlfiddle

Context

StackExchange Database Administrators Q#29701, answer score: 3

Revisions (0)

No revisions yet.