随笔 - 16  文章 - 0  trackbacks - 0
<2012年6月>
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

常用链接

留言簿

随笔档案

友情链接

搜索

  •  

最新评论

阅读排行榜

评论排行榜

--第一步,检查源表是否可以在线重定义
begin
DBMS_REDEFINITION.CAN_REDEF_TABLE (
   uname=>username,
   tname=>'T_DAR_DEPARBALANCE',
   options_flag=>dbms_redefinition.cons_use_pk);
end;

--第二步创建一张分区表做为中间表

  CREATE TABLE "username"."T_DAR_DEPARBALANCE_R"
   ( "FDEPARTID" VARCHAR2(44 BYTE) NOT NULL ENABLE,
 "FPERIODID" VARCHAR2(44 BYTE) NOT NULL ENABLE,
 "FCUSTOMERID" VARCHAR2(100 BYTE) NOT NULL ENABLE,
 "FBALTYPE" NUMBER(10,0) NOT NULL ENABLE,
 "FTRANSTYPE" NUMBER(10,0) NOT NULL ENABLE,
 "FBEGINBALANCE" NUMBER(20,4) DEFAULT 0 NOT NULL ENABLE,
 "FDEBIT" NUMBER(20,4) DEFAULT 0 NOT NULL ENABLE,
 "FCREDIT" NUMBER(20,4) DEFAULT 0 NOT NULL ENABLE,
 "FYEARDEBIT" NUMBER(20,4) DEFAULT 0 NOT NULL ENABLE,
 "FYEARCREDIT" NUMBER(20,4) DEFAULT 0 NOT NULL ENABLE,
 "FENDBALANCE" NUMBER(20,4) DEFAULT 0 NOT NULL ENABLE,
 "FCOMPANY" VARCHAR2(44 BYTE),
 "FWAYBILLNUM" VARCHAR2(44 BYTE) NOT NULL ENABLE,
 "FDESC" NVARCHAR2(255),
 "FREPAIRDESC" NVARCHAR2(255),
 "FBIZDATE" TIMESTAMP (6),
 "FPAYMENTTYPE" NUMBER(10,0),
  CONSTRAINT "PK_DEPARBALANCE_R" UNIQUE ("FDEPARTID", "FPERIODID", "FCUSTOMERID", "FBALTYPE", "FTRANSTYPE", "FWAYBILLNUM")
  USING INDEX TABLESPACE "EAS_ERP_IDX_FINANCE")
  TABLESPACE "EAS_ERP_D_FINANCE" partition by list (fperiodId)
  (
   PARTITION "2010-01" VALUES ('2yoe9wElEADgYH0hwKgCzII4jEw='),
   PARTITION "2010-02" VALUES ('2yoe9wElEADgYH0jwKgCzII4jEw='),
   PARTITION "2010-03" VALUES ('51KNiQElEADgAPZRwKgCZYI4jEw='),
   PARTITION "2010-04" VALUES ('51KNiQElEADgAPZTwKgCZYI4jEw='),
   PARTITION "2010-05" VALUES ('51KNiQElEADgAPZVwKgCZYI4jEw='),
   PARTITION "2010-06" VALUES ('51KNiQElEADgAPZXwKgCZYI4jEw='),
   PARTITION "2010-07" VALUES ('51KNiQElEADgAPZZwKgCZYI4jEw='),
   PARTITION "2010-08" VALUES ('51KNiQElEADgAPZbwKgCZYI4jEw='),
   PARTITION "2010-09" VALUES ('51KNiQElEADgAPZdwKgCZYI4jEw='),
   PARTITION "2010-10" VALUES ('51KNiQElEADgAPZfwKgCZYI4jEw='),
   PARTITION "2010-11" VALUES ('51KNiQElEADgAPZhwKgCZYI4jEw='),
   PARTITION "2010-12" VALUES ('51KNiQElEADgAPZjwKgCZYI4jEw='),
   PARTITION "2011-01" VALUES ('CalvogEtEADgD1KuwKgCzII4jEw='),
   PARTITION "2011-09" VALUES ('CalvogEtEADgD1NdwKgCzII4jEw='),
   PARTITION "2011-03" VALUES ('CalvogEtEADgD1MTwKgCzII4jEw='),
   PARTITION "2011-11" VALUES ('CalvogEtEADgD1N0wKgCzII4jEw='),
   PARTITION "2011-02" VALUES ('CalvogEtEADgD1MCwKgCzII4jEw='),
   PARTITION "2011-04" VALUES ('CalvogEtEADgD1MewKgCzII4jEw='),
   PARTITION "2011-06" VALUES ('CalvogEtEADgD1M4wKgCzII4jEw='),
   PARTITION "2011-10" VALUES ('CalvogEtEADgD1NuwKgCzII4jEw='),
   PARTITION "2011-08" VALUES ('CalvogEtEADgD1NPwKgCzII4jEw='),
   PARTITION "2011-12" VALUES ('CalvogEtEADgD1N4wKgCzII4jEw='),
   PARTITION "others" VALUES (DEFAULT)
   ) ENABLE ROW MOVEMENT ;
 

  CREATE INDEX "username"."IDX_T_DAR_DEPARBALANCE_COMP_R" ON "username"."T_DAR_DEPARBALANCE_R" ("FCOMPANY", "FPERIODID") local TABLESPACE "EAS_ERP_IDX_MINISTRY" ;
 
--拷备源表中的记录
begin
DBMS_REDEFINITION.START_REDEF_TABLE (
   uname=>username,
   orig_table=>'T_DAR_DEPARBALANCE',
   int_table=>'T_DAR_DEPARBALANCE_R',
   col_mapping=>NULL,
   options_flag=>dbms_redefinition.cons_use_pk,
   orderby_cols=>NULL,
   part_name=>NULL);
end;
  
--同步更新数据
begin
DBMS_REDEFINITION.SYNC_INTERIM_TABLE (
   uname=>username,
   orig_table=>'T_DAR_DEPARBALANCE',
   int_table=>'T_DAR_DEPARBALANCE_R',
   part_name=>NULL);

--转换完成  (注:在这一步源表会被锁住,一直到转换完成为止)
DBMS_REDEFINITION.FINISH_REDEF_TABLE (
   uname=>username,
   orig_table=>'T_DAR_DEPARBALANCE',
   int_table=>'T_DAR_DEPARBALANCE_R',
   part_name=>NULL);
end;

  
  
--新增分区操作
ALTER TABLE "username"."T_DAR_DEPARBALANCE" ADD PARTITION "2012-01" VALUES ('xxxxxxxxxxxx');

说明:请将username替换成实际的用户名;
  

posted on 2012-06-18 09:23 民工二代 阅读(344) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: