ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 數據表分區分割與刪除歷史數據

數據表分區分割與刪除歷史數據

原创 Linux操作系统 作者:aishu521 时间:2012-08-10 09:44:31 0 删除 编辑

1,查詢

PMMSTKNWIP;select * from PMMSTKNWIP

2,分割分區

ALTER TABLE PMMSTKNWIP SPLIT PARTITION P2011
AT('20120101')
INTO (PARTITION P2011,PARTITION P2012);

ALTER TABLE PMMSTKNWIP SPLIT PARTITION P2012
AT('20130101')
INTO (PARTITION P2012,PARTITION P2013);

3,刪除分區,同時刪除數據

ALTER TABLE PMMSTKNWIP drop  PARTITION P2010;
ALTER TABLE PMMSTKNWIP drop  PARTITION P2011;

4,刪除索引

ALTER TABLE PMMSTKNWIP
MODIFY PRIMARY KEY disable;------對主鍵
 drop index PK_MSTKNWI ;
-- Create/Recreate indexes
drop index IDX_0002;
drop index IDX_0006;
drop index IDX_0007 ;
drop index IDX_001 ;
drop index IDX_003 ;
drop index IDX_004 ;
drop index IDX_COMBINE ;
drop index INDEX_CONFDATE ;
drop index INDEX_PN ;

5,重建索引
ALTER TABLE PMMSTKNWIP
MODIFY PRIMARY KEY enable------主鍵

-- Create/Recreate indexes
create index IDX_0002 on PMMSTKNWIP (STKNWIP002)
  tablespace NDX_SFCDATA
  pctfree 10
  initrans 2
  maxtrans 255
  storage
  (
    initial 2M
    next 2M
    minextents 1
    maxextents unlimited
    pctincrease 0
  );
create index IDX_0006 on PMMSTKNWIP (STKNWIP006)
  tablespace NDX_SFCDATA
  pctfree 10
  initrans 2
  maxtrans 255
  storage
  (
    initial 2M
    next 2M
    minextents 1
    maxextents unlimited
    pctincrease 0
  );
create index IDX_0007 on PMMSTKNWIP (STKNWIP007)
  tablespace NDX_SFCDATA
  pctfree 10
  initrans 2
  maxtrans 255
  storage
  (
    initial 2M
    next 2M
    minextents 1
    maxextents unlimited
    pctincrease 0
  );
create index IDX_001 on PMMSTKNWIP (STKNWIP001)
  tablespace NDX_SFCDATA
  pctfree 10
  initrans 2
  maxtrans 255
  storage
  (
    initial 2M
    next 2M
    minextents 1
    maxextents unlimited
    pctincrease 0
  );
create index IDX_003 on PMMSTKNWIP (STKNWIP003)
  tablespace NDX_SFCDATA
  pctfree 10
  initrans 2
  maxtrans 255
  storage
  (
    initial 2M
    next 2M
    minextents 1
    maxextents unlimited
    pctincrease 0
  );
create index IDX_004 on PMMSTKNWIP (STKNWIP004)
  tablespace NDX_SFCDATA
  pctfree 10
  initrans 2
  maxtrans 255
  storage
  (
    initial 2M
    next 2M
    minextents 1
    maxextents unlimited
    pctincrease 0
  );
create index IDX_COMBINE on PMMSTKNWIP (STKNWIP001, STKNWIP002, STKNWIP006)
  tablespace NDX_SFCDATA
  pctfree 10
  initrans 2
  maxtrans 255
  storage
  (
    initial 2M
    next 2M
    minextents 1
    maxextents unlimited
    pctincrease 0
  );
create index INDEX_CONFDATE on PMMSTKNWIP (CONFDATE)
  tablespace NDX_SFCDATA
  pctfree 10
  initrans 2
  maxtrans 255
  storage
  (
    initial 2M
    next 2M
    minextents 1
    maxextents unlimited
    pctincrease 0
  );
create index INDEX_PN on PMMSTKNWIP (STKNWIP003, STKNWIP004, LAYER)
  tablespace NDX_SFCDATA
  pctfree 10
  initrans 2
  maxtrans 255
  storage
  (
    initial 2M
    next 2M
    minextents 1
    maxextents unlimited
    pctincrease 0
  );

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

下一篇: RAC安裝 參考
请登录后发表评论 登录
全部评论

注册时间:2012-05-26

  • 博文量
    139
  • 访问量
    721108