carlh
10-06-2006, 12:37 PM
Whats the proper syntax for partitioning a database in mysql? I'm using version 5.0.23, and all the samples i found have it formatted like this, but when I try to run it it says there is an error in the code
alter table `dnc`.`fed`
partition by range (`fullphone`)
(PARTITION p1 VALUES LESS THAN (1000000000),
PARTITION p2 VALUES LESS THAN (2000000000),
PARTITION p3 VALUES LESS THAN (3000000000),
PARTITION p4 VALUES LESS THAN (4000000000),
PARTITION p5 VALUES LESS THAN (5000000000),
PARTITION p6 VALUES LESS THAN (6000000000),
PARTITION p7 VALUES LESS THAN (7000000000),
PARTITION p8 VALUES LESS THAN (8000000000),
PARTITION p9 VALUES LESS THAN (9000000000),
PARTITION p10 VALUES LESS THAN (10000000000));
The error text is:
You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near 'partition by range(`fullphone`)
(PARTITION p1 VALUES LESS THAN (1000000000' at line 2
and it's error code #1064
and here's the sql for the create table:
CREATE TABLE `dnc`.`fed` (
`areacode` varchar(3) default NULL,
`phone` varchar(7) default NULL,
`fullphone` bigint(10) default NULL,
`dwnld_date` varchar(10) default NULL,
`qtr` varchar(1) default NULL,
`yr` varchar(2) default NULL,
UNIQUE KEY `U_FED` (`fullphone`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
edit: now that i'm re-reading it i think i might need to set the fullphone field to a primary key instead of unique key? The reason I had that setup as a unique key is sometimes the files i need to import to the table contain duplicates, so when i run my import with a unique key i can replace or ignore those records, but with a primary key it halts and gives an error
alter table `dnc`.`fed`
partition by range (`fullphone`)
(PARTITION p1 VALUES LESS THAN (1000000000),
PARTITION p2 VALUES LESS THAN (2000000000),
PARTITION p3 VALUES LESS THAN (3000000000),
PARTITION p4 VALUES LESS THAN (4000000000),
PARTITION p5 VALUES LESS THAN (5000000000),
PARTITION p6 VALUES LESS THAN (6000000000),
PARTITION p7 VALUES LESS THAN (7000000000),
PARTITION p8 VALUES LESS THAN (8000000000),
PARTITION p9 VALUES LESS THAN (9000000000),
PARTITION p10 VALUES LESS THAN (10000000000));
The error text is:
You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near 'partition by range(`fullphone`)
(PARTITION p1 VALUES LESS THAN (1000000000' at line 2
and it's error code #1064
and here's the sql for the create table:
CREATE TABLE `dnc`.`fed` (
`areacode` varchar(3) default NULL,
`phone` varchar(7) default NULL,
`fullphone` bigint(10) default NULL,
`dwnld_date` varchar(10) default NULL,
`qtr` varchar(1) default NULL,
`yr` varchar(2) default NULL,
UNIQUE KEY `U_FED` (`fullphone`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
edit: now that i'm re-reading it i think i might need to set the fullphone field to a primary key instead of unique key? The reason I had that setup as a unique key is sometimes the files i need to import to the table contain duplicates, so when i run my import with a unique key i can replace or ignore those records, but with a primary key it halts and gives an error