Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way that I can create a month-year partition on the below table? Without having to define all the permuations of month/year combos ?

CREATE TABLE  visitor_visits (
  id int(10) UNSIGNED NOT NULL auto_increment,
  visitor_id int(10) UNSIGNED NOT NULL,
  source varchar(64) NULL DEFAULT NULL DEFAULT NULL,
  medium varchar(64) NULL DEFAULT NULL,
  campaign varchar(256) NULL DEFAULT NULL,
  page varchar(32) NULL DEFAULT NULL,
  landing varchar(32) NULL DEFAULT NULL,
  type enum('fundraiser_view') NULL DEFAULT NULL,
  visit_date date NOT NULL default '0000-00-00',
  created_at datetime NOT NULL default '0000-00-00 00:00:00',

ALTER TABLE visitor_visits ADD UNIQUE INDEX (visitor_id,type,visit_date);
ALTER TABLE visitor_visits ADD CONSTRAINT FK_visits_visitor_id FOREIGN KEY (visitor_id) REFERENCES visitors(id);
share|improve this question
Partitioning does not support foreign keys. – Abdul Manaf Jun 21 '12 at 4:45

Sorry, you must create the PARTITIONs yourself. I would do it in Perl; do you know that language, or some other?

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.