섹션 테이블의 조작 예
15334 단어 파티션 테이블
허허, 안에 RPS표 이름도 들어있어.
Add & Split
Add & Split
--------------------------------------------------------------------------
-- list partitioned table
--------------------------------------------------------------------------
-- truncate table acct_spct_inst_x_acct_amt;
drop table acct_spct_inst_x_acct_amt purge;
--ACCT_SPCT_INST_X_ACCT_AMT
create table ACCT_SPCT_INST_X_ACCT_AMT(
id number not null,
arm_account_list_id number not null,
account_number varchar2(20) not null,
amount number,
load_batch_number number default 1 not null,
CREATED_DATE date
)
partition by list (arm_account_list_id)
(
-- partition p_axa_null values (null) --used for adding new partition
partition p_axa_def values (default) -- used for splitting existed partition
);
--Primary Key
alter table ACCT_SPCT_INST_X_ACCT_AMT add(
constraint ACCT_SPCT_INST_X_ACCT_AMT_pk
primary key( id )
);
--Forien Key
alter table ACCT_SPCT_INST_X_ACCT_AMT add(
constraint ACCT_SPCT_INST_X_ACCT_AMT_fk
foreign key (arm_account_list_id)
references arm_account_list (id)
);
--index
create index acct_spct_inst_x_acct_amt_cb1 on acct_spct_inst_x_acct_amt( account_number,arm_account_list_id ) local;
-- create index acct_spct_inst_x_acct_amt_cb2 on acct_spct_inst_x_acct_amt( arm_account_list_id ) local;
--------------------------------------------------------------------------------
-- ***** add new partition for newly added arm_acct_list
--------------------------------------------------------------------------------
alter table acct_spct_inst_x_acct_amt add partition p_axa_1340000 values (1340000);
insert into acct_spct_inst_x_acct_amt
(id,
arm_account_list_id,
account_number,
amount,
load_batch_number,
created_date)
values
(ACCT_SPCT_INST_X_ACCT_AMT_S.nextval, 1340000, '123', 100, 1, sysdate);
commit;
alter table acct_spct_inst_x_acct_amt add partition p_axa_1340001 values (1340001);
insert into acct_spct_inst_x_acct_amt
(id,
arm_account_list_id,
account_number,
amount,
load_batch_number,
created_date)
values
(ACCT_SPCT_INST_X_ACCT_AMT_S.nextval, 1340001, '123', 200, 1, sysdate);
commit;
select * from acct_spct_inst_x_acct_amt partition (p_axa_1340000);
--------------------------------------------------------------------------------
-- ***** split partition for newly added arm_acct_list
--------------------------------------------------------------------------------
alter table acct_spct_inst_x_acct_amt split partition p_axa_def values (1340000)
into (partition p_axa_1340000,partition p_axa_def) update indexes;
-------------------------------------------------------------------------------
-- table for exchange with same structrue and indexes
-------------------------------------------------------------------------------
drop table ACCT_SPCT_INST_X_ACCT_AMT_EX;
create table ACCT_SPCT_INST_X_ACCT_AMT_EX(
id number not null,
arm_account_list_id number not null,
account_number varchar2(20) not null,
amount number,
load_batch_number number default 1 not null,
CREATED_DATE date
);
--index
create index acct_spct_inst_x_a_amt_ex_cb1 on acct_spct_inst_x_acct_amt_ex( account_number,arm_account_list_id ) ;
-- create index acct_spct_inst_x_a_amt_ex_cb2 on acct_spct_inst_x_acct_amt_ex( arm_account_list_id ) ;
insert into acct_spct_inst_x_acct_amt_ex
(id,
arm_account_list_id,
account_number,
amount,
load_batch_number,
created_date)
values
(ACCT_SPCT_INST_X_ACCT_AMT_S.nextval, 1340000, '123', 1000, 2, sysdate);
commit;
-- truncate table acct_spct_inst_x_acct_amt_ex;
select * from acct_spct_inst_x_acct_amt_ex;
-------------------------------------------------------------------------------
-- exchange
-------------------------------------------------------------------------------
-- 1.disable constraint 2.exchange with index 3.enable constraint
alter table acct_spct_inst_x_acct_amt disable constraint ACCT_SPCT_INST_X_ACCT_AMT_pk keep index;
alter table acct_spct_inst_x_acct_amt disable constraint ACCT_SPCT_INST_X_ACCT_AMT_fk keep index;
alter table acct_spct_inst_x_acct_amt
exchange partition p_axa_1340000 with table acct_spct_inst_x_acct_amt_ex
including indexes update indexes;
alter table acct_spct_inst_x_acct_amt enable constraint ACCT_SPCT_INST_X_ACCT_AMT_pk ;
alter table acct_spct_inst_x_acct_amt enable constraint ACCT_SPCT_INST_X_ACCT_AMT_fk;
-- check index status
select t.table_name,t.partition_name from user_tab_partitions t where t.table_name = 'ACCT_SPCT_INST_X_ACCT_AMT';
select i.index_name, i.status from user_indexes i where i.table_name = 'ACCT_SPCT_INST_X_ACCT_AMT';
select i.index_name,i.partition_name,i.status from user_ind_partitions i where i.index_name in ('ACCT_SPCT_INST_X_ACCT_AMT_CB1','ACCT_SPCT_INST_X_ACCT_AMT_CB2');
-- relative package
select o.object_name, o.object_type, o.status from user_objects o where o.object_name = 'RPS_ARM_RUNTIME' ;
alter package RPS_ARM_RUNTIME compile;
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
섹션 테이블의 조작 예원래의 노트, 구역표를 조작하는 예(증가, 삭제, 구역 전환 등) 허허, 안에 RPS표 이름도 들어있어....
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.