MySQL数据库管理之如何创建分区表
下面一起来了解下MySQL数据库管理之如何创建分区表,相信大家看完肯定会受益匪浅,文字在精不在多,希望MySQL数据库管理之如何创建分区表这篇短内容是你想要的。
创新互联专注于企业成都营销网站建设、网站重做改版、莱山网站定制设计、自适应品牌网站建设、H5开发、购物商城网站建设、集团公司官网建设、成都外贸网站建设、高端网站制作、响应式网页设计等建站业务,价格优惠性价比高,为莱山等各大城市提供网站开发制作服务。
创建分区表 mysql> CREATE TABLE `LINEITEM` ( L_SHIPDATE DATE NULL, L_ORDERKEY INT NOT NULL, L_DISCOUNT DECIMAL(10,2) NOT NULL, L_EXTENDEDPRICE DECIMAL(10,2) NOT NULL, L_SUPPKEY INT NOT NULL, L_QUANTITY INT NOT NULL, L_RETURNFLAG CHAR(1) BINARY NULL, L_PARTKEY INT NOT NULL, L_LINESTATUS CHAR(1) BINARY NULL, L_TAX DECIMAL(10,2) NOT NULL, L_COMMITDATE DATE NULL, L_RECEIPTDATE DATE NULL, L_SHIPMODE CHAR(10) BINARY NULL, L_LINENUMBER INT NOT NULL, L_SHIPINSTRUCT CHAR(25) BINARY NULL, L_COMMENT VARCHAR(44) BINARY NULL, PRIMARY KEY (`L_ORDERKEY`, `L_LINENUMBER`,`L_SHIPDATE`) ) PARTITION BY RANGE COLUMNS (L_SHIPDATE) ( PARTITION p0 VALUES LESS THAN ('1993-01-01'), PARTITION p1 VALUES LESS THAN ('1994-01-01'), PARTITION p2 VALUES LESS THAN ('1995-01-01'), PARTITION p3 VALUES LESS THAN ('1996-01-01'), PARTITION p4 VALUES LESS THAN ('1997-01-01'), PARTITION p5 VALUES LESS THAN ('1998-01-01'), PARTITION p6 VALUES LESS THAN ('1999-01-01'), PARTITION p7 VALUES LESS THAN (MAXVALUE) ) 删除 mysql> ALTER TABLE lineitem DROP PARTITION p7; 增加 mysql> ALTER TABLE lineitem ADD PARTITION (PARTITION p7 VALUES LESS THAN ('2000-01-01')); 拆分 mysql> ALTER TABLE lineitem REORGANIZE PARTITION p0 INTO ( PARTITION p199206 VALUES LESS THAN ('1992-07-01'), PARTITION p199212 VALUES LESS THAN ('1993-01-01') ); 合并 mysql> ALTER TABLE lineitem REORGANIZE PARTITION p199206,p199212 INTO ( PARTITION p0 VALUES LESS THAN ('1993-01-01') ); 交换分区 mysql> CREATE TABLE `temp1992` ( `L_SHIPDATE` date NOT NULL DEFAULT '0000-00-00', `L_ORDERKEY` int(11) NOT NULL, `L_DISCOUNT` decimal(10,2) NOT NULL, `L_EXTENDEDPRICE` decimal(10,2) NOT NULL, `L_SUPPKEY` int(11) NOT NULL, `L_QUANTITY` int(11) NOT NULL, `L_RETURNFLAG` char(1) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, `L_PARTKEY` int(11) NOT NULL, `L_LINESTATUS` char(1) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, `L_TAX` decimal(10,2) NOT NULL, `L_COMMITDATE` date DEFAULT NULL, `L_RECEIPTDATE` date DEFAULT NULL, `L_SHIPMODE` char(10) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, `L_LINENUMBER` int(11) NOT NULL, `L_SHIPINSTRUCT` char(25) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, `L_COMMENT` varchar(44) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, PRIMARY KEY (`L_ORDERKEY`,`L_LINENUMBER`,`L_SHIPDATE`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 mysql> ALTER TABLE lineitem EXCHANGE PARTITION p0 WITH TABLE temp1992; Query OK, 0 rows affected (0.24 sec)
看完MySQL数据库管理之如何创建分区表这篇文章后,很多读者朋友肯定会想要了解更多的相关内容,如需获取更多的行业信息,可以关注我们的行业资讯栏目。
文章题目:MySQL数据库管理之如何创建分区表
标题链接:http://scyingshan.cn/article/ghjhho.html