日期:2014-05-16 浏览次数:21176 次
create table DATA_MODEL_FINAL ( OBJID NUMBER not null, OBJUSERID VARCHAR2(20), OBJELEVATION FLOAT, GROUPID VARCHAR2(20) default 0 ); create bitmap index GROUPID_model_index on data_model_final(GROUPID); create unique index objuserid_index on data_model_final(objuserid); create table DATA_PIPE_FINAL ( OBJID NUMBER not null, STARPOINTELEVATION FLOAT, GROUPID VARCHAR2(20) default 0, START_POINT VARCHAR2(20) ); create index START_POINT_index on data_pipe_final(START_POINT); create bitmap index GROUPID_pipe_index on data_pipe_final(GROUPID); insert into DATA_MODEL_FINAL (OBJID,OBJUSERID,OBJELEVATION,GROUPID) values (1910615,'AJ31123',0,'0201'); insert into DATA_MODEL_FINAL (OBJID,OBJUSERID,OBJELEVATION,GROUPID) values (1910616,'AJ31124',0,'0202'); insert into DATA_MODEL_FINAL (OBJID,OBJUSERID,OBJELEVATION,GROUPID) values (1910617,'AJ31125',0,'0203'); insert into DATA_MODEL_FINAL (OBJID,OBJUSERID,OBJELEVATION,GROUPID) values (1910618,'AJ31126',0,'0204'); insert into DATA_MODEL_FINAL (OBJID,OBJUSERID,OBJELEVATION,GROUPID) values (1910619,'AJ31127',0,'0204'); insert into DATA_MODEL_FINAL (OBJID,OBJUSERID,OBJELEVATION,GROUPID) values (1910620,'AJ31128',0,'0204'); insert into data_pipe_final (OBJID,START_POINT,STARPOINTELEVATION,GROUPID) values (201101,'AJ31126',1.5,'0104'); insert into data_pipe_final (OBJID,START_POINT,STARPOINTELEVATION,GROUPID) values (201102,'B000001',1.8,'0101'); insert into data_pipe_final (OBJID,START_POINT,STARPOINTELEVATION,GROUPID) values (201103,'AJ31126',2.2,'0104'); insert into data_pipe_final (OBJID,START_POINT,STARPOINTELEVATION,GROUPID) values (201104,'AJ31126',1.5,'0104'); insert into data_pipe_final (OBJID,START_POINT,STARPOINTELEVATION,GROUPID) values (201105,'AJ31127',1.5,'0104'); insert into data_pipe_final (OBJID,START_POINT,STARPOINTELEVATION,GROUPID) values (201106,'AJ31127',1.9,'0104');
UPDATE DATA_MODEL_FINAL A SET OBJELEVATION=(SELECT MAX(B.STARPOINTELEVATION) FROM DATA_PIPE_FINAL B WHERE B.GROUPID='0104' AND B.START_POINT=A.OBJUSERID ) WHERE A.GROUPID='0204';
merge into DATA_MODEL_FINAL A using DATA_PIPE_FINAL B on (B.GROUPID='0104' AND A.GROUPID='0204' AND B.START_POINT=A.OBJUSERID) when matched then update set A.OBJELEVATION=MAX(B.STARPOINTELEVATION)
merge into DATA_MODEL_FINAL A using (SELECT MAX(STARPOINTELEVATION) as STARPOINTELEVATION, START_POINT FROM DATA_PIPE_FINAL WHERE GROUPID='0104' group by START_POINT) b on (A.GROUPID='0204' AND B.START_POINT=A.OBJUSERID) when matched then update set A.OBJELEVATION=MAX(B.STARPOINTELEVATION)