我想对表进行分区,此代码将向您显示表的结构。该表目前有大约 500 万条记录。
我需要这个表的 MySql 分区语法,就像这样
主分区是归档的 trigger_on 分区类型范围“按年份”,然后按字段的子分区称为状态。
如何在这个现有表上创建分区/子分区?
CREATE TABLE `phone_calls` (
`phone_call_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`account_id` int(11) unsigned NOT NULL,
`team_id` int(11) unsigned NOT NULL,
`call_code_id` int(11) unsigned NOT NULL,
`result_code_id` int(11) unsigned NOT NULL DEFAULT '0',
`trigger_on` datetime NOT NULL,
`created_on` datetime NOT NULL,
`first_attempt_on` datetime DEFAULT NULL,
`first_attempt_by` int(11) unsigned DEFAULT NULL,
`call_subject` char(100) NOT NULL,
`status` tinyint(1) NOT NULL COMMENT '0= purge, 1=active, 2 = completed', `workflow_generated` tinyint(1) NOT NULL DEFAULT '0' COMMENT '1= generated by system flow, 0 created by a user',
`last_attempt_on` datetime DEFAULT NULL,
`last_attempt_by` int(11) unsigned DEFAULT NULL,
`total_attempts` tinyint(3) unsigned NOT NULL DEFAULT '0',
`modified_by` int(11) unsigned DEFAULT NULL,
`last_call_id` int(11) unsigned NOT NULL,
`call_direction` enum('INBOUND','OUTBOUND') NOT NULL COMMENT 'INBOUND or OUTBOUND', `call_notes` text NOT NULL,
`owner_id` int(11) NOT NULL,
`call_duration` smallint(5) unsigned NOT NULL DEFAULT '0',
`modified_on` datetime DEFAULT NULL,
PRIMARY KEY (`phone_call_id`),
KEY `owner_id` (`owner_id`),
KEY `call_code_id` (`call_code_id`),
KEY `result_code_id` (`result_code_id`),
KEY `account_id` (`account_id`),
KEY `trigger_on` (`trigger_on`),
KEY `created_on` (`created_on`),
KEY `status` (`status`),
KEY `pcto` (`trigger_on`,`status`,`owner_id`))
ENGINE=InnoDB
AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4