How to UPDATE all columns of a record without having to list every column

后端 未结 8 1857
情歌与酒
情歌与酒 2020-12-29 03:20

I\'m trying to figure out a way to update a record without having to list every column name that needs to be updated.

For instance, it would be nice if I could use so

8条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-29 03:44

    If you are using Oracle, you can use rowtype

    declare 
        var_x  TABLE_A%ROWTYPE;
    Begin
        select * into var_x
        from TABLE_B where rownum = 1;
    
        update TABLE_A set row = var_x
        where ID = var_x.ID;
    end;
    /
    

    given that TABLE_A and TABLE_B are of same schema

提交回复
热议问题