ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 分区表的truncate

分区表的truncate

原创 Linux操作系统 作者:lsq_008 时间:2008-04-29 12:59:58 0 删除 编辑
Truncating Table Partitions Containing Data and Global Indexes

If the partition contains data and global indexes, use one of the following methods to truncate the table partition.

方法1 。先truncate,后rebuild全局索引。

ALTER TABLE sales TRUNCATE PARTITION dec98;
ALTER INDEX sales_area_ix REBUILD;

此法适合于分区表含有大量数据的情况。

方法 2:先delete所有数据,后truncate

DELETE FROM sales WHERE TRANSID < 10000;
ALTER TABLE sales TRUNCATE PARTITION dec98;

此法适合于分区表数据量较小的情况。

方法3:truncate同时带UPDATE GLOBAL INDEXES子句

ALTER TABLE sales TRUNCATE PARTITION dec98
     UPDATE GLOBAL INDEXES

此法在truncate分区的同时将该分区上的索引也truncate

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/10972173/viewspace-255726/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
十余年大型金融及电信系统数据库管理经验,曾服务于中国建设银行、中国移动。对oracle,mysql数据库有深入了解。 擅长python开发,独立开发了开源数据库自动化监控运维平台Power Monitor。

注册时间:2008-02-29

  • 博文量
    335
  • 访问量
    1369107