把拆分成下图  一开始我的想法是创建个备份表,然后备份表update成50%,原表update成50%,再把备份表的数据复制到原表里 

解决方案 »

  1.   

    先UPDATE 50%,然后再insert into 一次全表
      

  2.   

    CREATE TABLE  test_t(ID,name,sal) AS
              SELECT 1,'a',2000 FROM dual
    UNION ALL SELECT 2,'b',3000 FROM dual
    UNION ALL SELECT 3,'c',2500 FROM dual;
    --SELECT *  FROM test_t;
    INSERT INTO test_t t1 SELECT * FROM test_t t2;
    COMMIT;
    UPDATE test_t SET sal=0.5*sal ;
    COMMIT;
      

  3.   

    with tb1 as
     (SELECT 1 fd1, 'a' fd2, 2000 fd3
        FROM dual
      UNION ALL
      SELECT 2 fd1, 'b' fd2, 3000 fd3
        FROM dual
      UNION ALL
      SELECT 3 fd1, 'c' fd2, 2500 fd3
        FROM dual),
    tb2 as
     (select 2 fd1 from dual union all select 2 fd1 from dual)
    select a.fd1, a.fd2, a.fd3 / b.fd1 from tb1 a, tb2 b
      

  4.   

    --1.建表
     create table test_A
     (
            ID varchar(20) ,
            name varchar(20),
            sal int
     
     );
    --2.插入测试数据
    insert into test_A values('1','a',2000);
     insert into test_A values('2','b',3000);
     insert into test_A values('3','c',2500);
    --3.按百分比加工,并在name字段拼一个test
    insert into test_A (select 'test'||ID ,name,sal*0.5 from test_A union all select 'test'||ID ,name,sal*0.5 from test_A)
    --4.删除原来的数据
     select * from test_A t where instr(t.name,'test')=0
    --5.将name后面的test去掉
    update test_A t  set name=substr(t.name,5,length(t.name));