在mysql中使用区间分区

在mysql中使用区间分区,第1张

我尝试使用MYSQLMicrosoft Sql学到的知识来学习Oracle。我尝试在桌面上使用间隔分区,但我没有看到我遇到的错误的解决方案。

create table telmar_php.call_log
(
 log_id int not null,
 sender int,
 reciever varchar(30) not null,
 call_duration TIMESTAMP,
 call_start TIMESTAMP,
 call_end TIMESTAMP,
 primary key (log_id),
 foreign key(sender) references number_assigned(sender)
)
partition by RANGE (call_duration) //This is the error line
INTERVAL(NUMTODSINTERVAL(1, 'HOUR')) 
(PARTITION "2015-03-15 00:00:00" VALUES LESS THAN (TO_DATE ('2015-03-16 00', 'YYYY-MM-DD hh24', 'NLS_CALENDAR=GREGORIAN')));

代码是你不能在MYSQL中使用区间分区?

最佳答案:

2 个答案:

答案 0 :(得分:1)

Oracle将允许您使用间隔进行分区,例如:

create table pos_data ( start_date DATE, store_id NUMBER, inventory_id NUMBER(6), qty_sold NUMBER(3) ) PARTITION BY RANGE (start_date) INTERVAL(NUMTOYMINTERVAL(1, 'MONTH')) (
PARTITION pos_data_p1 VALUES LESS THAN (TO_DATE('1-7-2007', 'DD-MM-YYYY')) );

但是,如果要在mysql中进行分区,则必须明确定义每个分区,如下所示:

CREATE TABLE tblemployeepunch ( fld_id int(11) NOT NULL AUTO_INCREMENT, fld_date Varchar(15) DEFAULT NULL, fld_rawpunchdate varchar(25) DEFAULT NULL, fld_rawpunchtime varchar(25) DEFAULT NULL, fld_cardno varchar(50) DEFAULT NULL, fld_reasoncard varchar(20) DEFAULT NULL, fld_mode varchar(20) DEFAULT NULL, fld_punchdatetime varchar(50) DEFAULT NULL, fld_crtdate TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY fld_id (fld_id,fld_crtdate), KEY in_timesheet (fld_cardno,fld_punchdatetime,fld_mode,fld_rawpunchtime), KEY in_emppunch (fld_cardno,fld_rawpunchdate,fld_punchdatetime) ) PARTITION BY RANGE (UNIX_TIMESTAMP(fld_crtdate)) (PARTITION p_Sep12 VALUES LESS THAN (UNIX_TIMESTAMP('2012-10-01 00:00:00')), PARTITION p_Oct12 VALUES LESS THAN (UNIX_TIMESTAMP('2012-11-01 00:00:00')), PARTITION p_Nov12 VALUES LESS THAN (UNIX_TIMESTAMP('2012-12-01 00:00:00')), PARTITION p_Max VALUES LESS THAN MAXVALUE );

答案 1 :(得分:0)

与Oracle不同,MySQL不支持间隔分区。您必须明确定义每个分区。

本文经用户投稿或网站收集转载,如有侵权请联系本站。

发表评论

0条回复