編排箱號舊資料的備份

longwansheng發表於2009-03-31

編排箱號是自主開發的,其TABLE也是自主CREATION的。故隻保留最近2年的,把2年前的或已不用的ORG的資料轉到備份TABLE中。

這樣可以提升編排箱號畫面的速度。

[@more@]

編排箱號相關的自主CREATION的TABLE有:

SUMMARY: gobo_om_ship_header_all

DETAIL: gobo_om_ship_line_all

並箱用的:gobo_ship_into_one

FRIST:

create table gobo_om_ship_line_bk2009 as
select * from gobo_om_ship_line_all
where 1=2

create table gobo_om_ship_header_bk2009 as
select * from gobo_om_ship_header_all
where 1=2


create table gobo_ship_into_one_bk2009 as
select * from gobo_ship_into_one
where 1=2

insert into gobo_om_ship_header_bk2009
select * from gobo_om_ship_header_all
where org_id in
(
2,3,4,5,6,7,8,9,10,11,12,13,58,487,179,201,202,203,483,491)

delete from gobo_om_ship_header_all
where org_id in
(
2,3,4,5,6,7,8,9,10,11,12,13,58,487,179,201,202,203,483,491)

insert into gobo_om_ship_header_bk2009
select * from gobo_om_ship_header_all a
where to_char(a.CREATION_DATE,'yyyy')

delete gobo_om_ship_header_all a
where to_char(a.CREATION_DATE,'yyyy')

commit

insert into gobo_om_ship_line_bk2009
select * from gobo_om_ship_line_all a
where not exists (select 1 from gobo_om_ship_header_all b
where b.ship_header_id=a.ship_header_id)

insert into gobo_ship_into_one_bk2009
select * from gobo_ship_into_one a
where not exists (select 1 from gobo_om_ship_header_all b
where b.ship_header_id=a.ship_header_id)

delete from gobo_om_ship_line_all a
where not exists (select 1 from gobo_om_ship_header_all b
where b.ship_header_id=a.ship_header_id)

delete from gobo_ship_into_one a
where not exists (select 1 from gobo_om_ship_header_all b
where b.ship_header_id=a.ship_header_id)


commit


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/92289/viewspace-1019656/,如需轉載,請註明出處,否則將追究法律責任。

相關文章