0
我想分割一個表,這段代碼會告訴你表的結構。該表目前有大約500萬條記錄。如何將mysql表分區爲兩層?
我需要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
不能通過範圍'MySQL'子分區。 – Quassnoi 2013-03-26 19:52:40
然後我可以按日期分區,然後子分區由列「狀態」 – Jaylen 2013-03-26 19:56:30