본문 바로가기
mysql

파티셔닝 Partitioning

by [김경민]™ ┌(  ̄∇ ̄)┘™ 2018. 12. 17.
728x90


create table BusinessCard

(id int not null, name varchar(255), address varchar(255), telephone varchar(255), createtime date)

  partition by range(year(createtime))(

  partition p0 values less than (2013),

  partition p1 values less than (2014),

  partition p2 values less than (2015),

  partition p3 values less than MAXVALUE

);


show create table BusinessCard\G


insert into BusinessCard values (1, 'kim','seoul',' 123-456', '2000-01-01');

insert into BusinessCard values (2, 'lee','seoul',' 123-456', '2014-01-01');


explain partitions select * from BusinessCard where createtime >= '2014-01-01' \G


파티션 추가/삭제

alter table BusinessCard add partition(

   partition p4 values less than (2005));


alter table BusinessCard drop partition p4;


파티션 분할/병합

alter table BusinessCard

 reorganize partition p3 into (

 partition p3 values less than(2015), 

 partition p4 values less than MAXVALUE

);


alter table BusinessCard

 reorganize partition p2, p3 into (

 partition p23 values less than (2014));




728x90

댓글