Friday, 15 July 2011

database - How to partition by mysql table into two layers? -


I want to split a table This code will show you the structure of the table. There are currently around 5 million records in the table.

I need the MySQL partition syntax like this table

The main partition is the filed triggered partition type category by "year by year" then the field is called the status by subdivision.

How can I create a partition / subdivision on this current table?

  Create tab Fon_gls` ( `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 nULL, Ak` created_on` not datetime nULL,` first_attempt_on` datetime default zero, `first_attempt_by `Integer (11) unsigned default zero,` call_subject` four (100) not NULL, `status` tinyint (1) No NULL comment '0 = purge, 1 = active, 2 = complete', `workflow_generated` tinyint (1) not NULL default '0' comment '1 = generated by system flow,' created by user 0, 'last_attempt_on` datename DEFAULT zero `Last_attempt_by` int (11) unsigned default zero,` total_attempts` tinyint (3) unsigned nOT nULL default '0', `modified_by` int (11) unsigned default zero,` last_call_id` int (11) unsigned nOT zero, ` Call_direction` enum ('inbound', 'outbound') NULL comment 'Inba NULL default '0', `modified_on`, datetime default zero, primary key (` phone_call_id`), or 'outbound', `call_notes` text no NULL, integer (11), zero not owner_id`` call_duration` SMALLINT (5) unsigned ) Key `owner_id` (` owner_id`), KEY `call_code_id` (` call_code_id`), KEY `result_code_id` (` result_code_id`), KEY `Khata_aidi` (` Khata_aidi`), KEY `Trigr_on` (` Trigr_on` ), Key `created_on` (` created_on`), key` condition` (`condition`), key` pcto` (` trigger_on`, `condition`` owner_id`)) engine = InnoDB AUTO_INCREMENT = 1 default charset = ut F8mb4    

after "div class =" itemprop = "text">

try this SQL

  table Fonkalon` ( `Fon_col_aidi` eT (11) unsigned nOT nULL Autioansiarment,` Khata_aidi` I NT (11) unsigned nOT nULL, `team_id` int (11) unsigned nOT nULL,` call_code_id` int (11) unsigned nOT nULL , `Result_code_id` integer (11) unsigned NULL default '0',` trigger_on` datetime not zero, `created_on` datetime not NULL,` first_attempt_on` datetime default zero, `first_attempt _by` integer (11) unsigned default zero, `call_subject` four (100) not null,` status` tinyint (1) not null comment '0 = purge, 1 = active, 2 = complete', `workflow_generated` tinyint (1 ) No NULL default '0' comment '1 = system flux, 0 a' user, 'last_attempt_on` datetime integer generated by default zero, `last_attempt_by` (11) unsigned default zero,` total_attempts` tinyint (3) unsigned NULL default '0', `modified_by` integer (11) unsigned default zero,` last_call_id` Integer (11) unsigned NULL, `call_direction` enum ('inbound', 'outbound') NULL comment 'Inbound or outbound',` call_notes` text no NULL, `integer (11) zero zero owner_id` call_duration `SMALLINT (5) unsigned nOT nULL default '0', 'Snshodit_on' Detataim DE mistake zero, pRIMARY KEY (` phone_call_id`, `trigger_on`,` status`), Kunji` owner_id` ( `owner_id`), Kunji` call_code_id `(` Call_code_id`), key` result_code_id` (`result_code_id`), key` account_id` (`account_id`), key` trigger_on` (`trigger_on`), key` ban_o Key `position` (` condition`), key` pcto` (`trigger_on`,` condition` `owner_id`)) segment based on class (year (` trigger_on`)) HASH SUBPARTITION (`status`) SUBPARTITIONS 2 (low values ​​from partition p0 (1990), value less than PARTITION p1 MAXVALUE)   



No comments:

Post a Comment