with a as ( select 1 id,'a' a from dual union all select 2,'a' from dual union all select 3,'a' from dual union all select 4,'a' from dual union all select 5,'a' from dual union all select 6,'a' from dual ) select id,a,case when mod(id,2)=0 then a else 'b' end c , round(id/2) d from a
with tab as( select 1 id,'A' zu from dual union all select 2,'A' from dual union all select 3,'A' from dual union all select 4,'A' from dual union all select 5,'A' from dual union all select 6,'A' from dual ) select rownum id,zu from tab where id not in (1,3,5 ) union select rownum id,Decode(zu,'A','B') zu from tab where id in (1,3,5 )
--思路: --1、 create table tab_copy as select rownum id,zu from( select id,zu from tab where id not in (1,2 ) order by id ) union select rownum id,zu from( select id,'Z' zu from tab where id in (1,2 ) order by id )--2、 drop table tab--3、 alter table tab_copy rename tab --可以将上面的3个步骤放在procedure中,然后调用过程就是了,对于参数(1,2)是你传入参数,你可以用数组来作传入参数
(
select 1 id,'a' a from dual
union all
select 2,'a' from dual
union all
select 3,'a' from dual
union all
select 4,'a' from dual
union all
select 5,'a' from dual
union all
select 6,'a' from dual
)
select id,a,case when mod(id,2)=0 then a else 'b' end c , round(id/2) d from a
with tab as(
select 1 id,'A' zu from dual
union all
select 2,'A' from dual
union all
select 3,'A' from dual
union all
select 4,'A' from dual
union all
select 5,'A' from dual
union all
select 6,'A' from dual
)
select rownum id,zu from tab where id not in (1,3,5 )
union
select rownum id,Decode(zu,'A','B') zu from tab where id in (1,3,5 )
--思路:
--1、
create table tab_copy as
select rownum id,zu from(
select id,zu from tab where id not in (1,2 ) order by id
)
union
select rownum id,zu from(
select id,'Z' zu from tab where id in (1,2 ) order by id
)--2、
drop table tab--3、
alter table tab_copy rename tab
--可以将上面的3个步骤放在procedure中,然后调用过程就是了,对于参数(1,2)是你传入参数,你可以用数组来作传入参数
alter table tab_copy rename to tab ;