MyISAM分割槽表遷移 && 合併
dyn_change_yyyymm 是一張按照日期(欄位time_d)分割槽的表(myisam),只有insert,select操作。
2016年3月份起結構如下:
CREATE TABLE `dyn_change_201603` (
`time_d` int(8) NOT NULL COMMENT '帳期',
`id` char(32) NOT NULL COMMENT '業務標識',
`content` text COMMENT '內容',
`create_time` int(11) NOT NULL COMMENT '時間',
KEY `idx_id` (`id`),
KEY `idx_create_time` (`create_time`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='動態資料記錄表'
/*!50100 PARTITION BY RANGE (time_d)
(PARTITION dypt_20160301 VALUES LESS THAN (20160302) ENGINE = MyISAM,
PARTITION dypt_20160302 VALUES LESS THAN (20160303) ENGINE = MyISAM,
PARTITION dypt_20160303 VALUES LESS THAN (20160304) ENGINE = MyISAM,
PARTITION dypt_20160304 VALUES LESS THAN (20160305) ENGINE = MyISAM,
PARTITION dypt_20160305 VALUES LESS THAN (20160306) ENGINE = MyISAM,
PARTITION dypt_20160306 VALUES LESS THAN (20160307) ENGINE = MyISAM,
PARTITION dypt_20160307 VALUES LESS THAN (20160308) ENGINE = MyISAM,
PARTITION dypt_20160308 VALUES LESS THAN (20160309) ENGINE = MyISAM,
PARTITION dypt_20160309 VALUES LESS THAN (20160310) ENGINE = MyISAM,
PARTITION dypt_20160310 VALUES LESS THAN (20160311) ENGINE = MyISAM,
PARTITION dypt_20160311 VALUES LESS THAN (20160312) ENGINE = MyISAM,
PARTITION dypt_20160312 VALUES LESS THAN (20160313) ENGINE = MyISAM,
PARTITION dypt_20160313 VALUES LESS THAN (20160314) ENGINE = MyISAM,
PARTITION dypt_20160314 VALUES LESS THAN (20160315) ENGINE = MyISAM,
PARTITION dypt_20160315 VALUES LESS THAN (20160316) ENGINE = MyISAM,
PARTITION dypt_20160316 VALUES LESS THAN (20160317) ENGINE = MyISAM,
PARTITION dypt_20160317 VALUES LESS THAN (20160318) ENGINE = MyISAM,
PARTITION dypt_20160318 VALUES LESS THAN (20160319) ENGINE = MyISAM,
PARTITION dypt_20160319 VALUES LESS THAN (20160320) ENGINE = MyISAM,
PARTITION dypt_20160320 VALUES LESS THAN (20160321) ENGINE = MyISAM,
PARTITION dypt_20160321 VALUES LESS THAN (20160322) ENGINE = MyISAM,
PARTITION dypt_20160322 VALUES LESS THAN (20160323) ENGINE = MyISAM,
PARTITION dypt_20160323 VALUES LESS THAN (20160324) ENGINE = MyISAM,
PARTITION dypt_20160324 VALUES LESS THAN (20160325) ENGINE = MyISAM,
PARTITION dypt_20160325 VALUES LESS THAN (20160326) ENGINE = MyISAM,
PARTITION dypt_20160326 VALUES LESS THAN (20160327) ENGINE = MyISAM,
PARTITION dypt_20160327 VALUES LESS THAN (20160328) ENGINE = MyISAM,
PARTITION dypt_20160328 VALUES LESS THAN (20160329) ENGINE = MyISAM,
PARTITION dypt_20160329 VALUES LESS THAN (20160330) ENGINE = MyISAM,
PARTITION dypt_20160330 VALUES LESS THAN (20160331) ENGINE = MyISAM,
PARTITION dypt_20160331 VALUES LESS THAN (20160401) ENGINE = MyISAM) */
在不影響insert的情況下,需要將dyn_change_201603遷移到新環境下。
步驟如下:
1)假設當前日期為:2016年3月30日,對應分割槽dypt_20160330,新環境建立dyn_change_201603表(非分割槽表)。insert 操作可以移到新環境下;
2)將老環境下的表dyn_change_201603 重新命名為: dyn_change_201603_old;
3)到mysql的資料目錄下,將dyn_change_201603_old的資料檔案&&索引檔案scp到新環境對應的路徑下面。[注:dyn_change_201603_old此時的對應資料&&索引檔案不同與dyn_change_201603的資料&&索引檔案]
4)然後交換dyn_change_201603,dyn_change_201603_old表名。交換後,90%以上的資料都在dyn_change_201603表,而少部分資料在dyn_change_201603_old(只在分割槽dypt_20160330 中);
dyn_change_201603接受當前insert操作;
5)然後匯出dyn_change_201603_old 的dypt_20160330分割槽的資料(僅有少量資料),可以匯出dyn_change_201603_30.csv檔案;
6)然後將dyn_change_201603_30.csv的資料匯入dyn_change_201603;
7)alter table dyn_change_201603 analyze partition dypt_20160330。 [注:此時可在insert操作較少的時間 or 暫停insert 操作]。
遷移合併完成。
2016年3月份起結構如下:
CREATE TABLE `dyn_change_201603` (
`time_d` int(8) NOT NULL COMMENT '帳期',
`id` char(32) NOT NULL COMMENT '業務標識',
`content` text COMMENT '內容',
`create_time` int(11) NOT NULL COMMENT '時間',
KEY `idx_id` (`id`),
KEY `idx_create_time` (`create_time`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='動態資料記錄表'
/*!50100 PARTITION BY RANGE (time_d)
(PARTITION dypt_20160301 VALUES LESS THAN (20160302) ENGINE = MyISAM,
PARTITION dypt_20160302 VALUES LESS THAN (20160303) ENGINE = MyISAM,
PARTITION dypt_20160303 VALUES LESS THAN (20160304) ENGINE = MyISAM,
PARTITION dypt_20160304 VALUES LESS THAN (20160305) ENGINE = MyISAM,
PARTITION dypt_20160305 VALUES LESS THAN (20160306) ENGINE = MyISAM,
PARTITION dypt_20160306 VALUES LESS THAN (20160307) ENGINE = MyISAM,
PARTITION dypt_20160307 VALUES LESS THAN (20160308) ENGINE = MyISAM,
PARTITION dypt_20160308 VALUES LESS THAN (20160309) ENGINE = MyISAM,
PARTITION dypt_20160309 VALUES LESS THAN (20160310) ENGINE = MyISAM,
PARTITION dypt_20160310 VALUES LESS THAN (20160311) ENGINE = MyISAM,
PARTITION dypt_20160311 VALUES LESS THAN (20160312) ENGINE = MyISAM,
PARTITION dypt_20160312 VALUES LESS THAN (20160313) ENGINE = MyISAM,
PARTITION dypt_20160313 VALUES LESS THAN (20160314) ENGINE = MyISAM,
PARTITION dypt_20160314 VALUES LESS THAN (20160315) ENGINE = MyISAM,
PARTITION dypt_20160315 VALUES LESS THAN (20160316) ENGINE = MyISAM,
PARTITION dypt_20160316 VALUES LESS THAN (20160317) ENGINE = MyISAM,
PARTITION dypt_20160317 VALUES LESS THAN (20160318) ENGINE = MyISAM,
PARTITION dypt_20160318 VALUES LESS THAN (20160319) ENGINE = MyISAM,
PARTITION dypt_20160319 VALUES LESS THAN (20160320) ENGINE = MyISAM,
PARTITION dypt_20160320 VALUES LESS THAN (20160321) ENGINE = MyISAM,
PARTITION dypt_20160321 VALUES LESS THAN (20160322) ENGINE = MyISAM,
PARTITION dypt_20160322 VALUES LESS THAN (20160323) ENGINE = MyISAM,
PARTITION dypt_20160323 VALUES LESS THAN (20160324) ENGINE = MyISAM,
PARTITION dypt_20160324 VALUES LESS THAN (20160325) ENGINE = MyISAM,
PARTITION dypt_20160325 VALUES LESS THAN (20160326) ENGINE = MyISAM,
PARTITION dypt_20160326 VALUES LESS THAN (20160327) ENGINE = MyISAM,
PARTITION dypt_20160327 VALUES LESS THAN (20160328) ENGINE = MyISAM,
PARTITION dypt_20160328 VALUES LESS THAN (20160329) ENGINE = MyISAM,
PARTITION dypt_20160329 VALUES LESS THAN (20160330) ENGINE = MyISAM,
PARTITION dypt_20160330 VALUES LESS THAN (20160331) ENGINE = MyISAM,
PARTITION dypt_20160331 VALUES LESS THAN (20160401) ENGINE = MyISAM) */
在不影響insert的情況下,需要將dyn_change_201603遷移到新環境下。
步驟如下:
1)假設當前日期為:2016年3月30日,對應分割槽dypt_20160330,新環境建立dyn_change_201603表(非分割槽表)。insert 操作可以移到新環境下;
2)將老環境下的表dyn_change_201603 重新命名為: dyn_change_201603_old;
3)到mysql的資料目錄下,將dyn_change_201603_old的資料檔案&&索引檔案scp到新環境對應的路徑下面。[注:dyn_change_201603_old此時的對應資料&&索引檔案不同與dyn_change_201603的資料&&索引檔案]
4)然後交換dyn_change_201603,dyn_change_201603_old表名。交換後,90%以上的資料都在dyn_change_201603表,而少部分資料在dyn_change_201603_old(只在分割槽dypt_20160330 中);
dyn_change_201603接受當前insert操作;
5)然後匯出dyn_change_201603_old 的dypt_20160330分割槽的資料(僅有少量資料),可以匯出dyn_change_201603_30.csv檔案;
6)然後將dyn_change_201603_30.csv的資料匯入dyn_change_201603;
7)alter table dyn_change_201603 analyze partition dypt_20160330。 [注:此時可在insert操作較少的時間 or 暫停insert 操作]。
遷移合併完成。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9606353/viewspace-2089200/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle分割槽表遷移Oracle
- 分割槽表分批遷移
- 全面學習分割槽表及分割槽索引(11)--合併表分割槽索引
- 【實驗】【PARTITION】RANGE分割槽表合併分割槽
- 分割槽表對應的表空間遷移案例
- MySQL分割槽如何遷移MySql
- 合併分割槽(coalesce partition)
- Oracle 12C 新特性之表分割槽或子分割槽的線上遷移Oracle
- win10怎麼合併分割槽_win10合併分割槽的方法Win10
- mac分割槽合併APFS容器Mac
- MapReduce(三):分割槽、排序、合併排序
- 【實驗】【PARTITION】RANGE分割槽表移動表分割槽(Move Partition)
- win10u盤分割槽怎麼合併 win10如何把U分割槽合併Win10
- Win10系統怎麼合併磁碟分割槽 win10合併磁碟分割槽的方法Win10
- Oracle分割槽表基礎運維-05組合分割槽Oracle運維
- 海量資料遷移之分割槽表批次insert效能改進
- 海量資料遷移之分割槽表批量insert效能改進
- 全面學習分割槽表及分割槽索引(6)--建立range-list組合分割槽索引
- win10分割槽合併不了的解決方法_win10分割槽合併不了如何處理Win10
- Oracle 11g 分割槽拆分與合併Oracle
- 深入學習分割槽表及分割槽索引(5)--建立range-hash組合分割槽(續)索引
- oracle分割槽表和分割槽表exchangeOracle
- 海量資料遷移之分割槽並行抽取並行
- 海量資料遷移之分割槽並行切分並行
- partition 分割槽表移動到其他表空間
- 批量移動分割槽表到其他表空間
- 全面學習分割槽表及分割槽索引(13)--分隔表分割槽索引
- oracle分割槽表和非分割槽表exchangeOracle
- Oracle分割槽表及分割槽索引Oracle索引
- INTERVAL分割槽表鎖分割槽操作
- 全面學習分割槽表及分割槽索引(9)--刪除表分割槽索引
- 全面學習分割槽表及分割槽索引(12)--修改list表分割槽索引
- 學習筆記】分割槽表和分割槽索引——新增表分割槽(二)筆記索引
- 資料泵引數partition_options 在對於遷移分割槽表的使用。
- 如何查詢分割槽表的分割槽及子分割槽
- Windows7系統硬碟合併分割槽的方法Windows硬碟
- 使用split對分割槽表再分割槽
- 簡單ORACLE分割槽表、分割槽索引Oracle索引