修改字段信息

--添加ID字段
alter table UTDICTIONARYT_TEMP drop column ID;
alter table UTDICTIONARYT_TEMP add ID number;
--创建存储过程
CREATE OR REPLACE PROCEDURE TEST_TEMPINFO is
    cursor 
        crs_ut 
    is 
        select * from utdictionaryt_temp for update;
        var_index_id NUMBER;
BEGIN
         var_index_id := 1;
         FOR r_ut in crs_ut LOOP
             UPDATE utdictionaryt_temp SET id = var_index_id WHERE current of crs_ut;
             var_index_id := var_index_id + 1;
          END LOOP;
END;
/
COMMIT;
execute test_tempinfo;
commit;
--添加主键
alter table UTDICTIONARYT_TEMP add constraint utdictionaryT_TEMP_1001 primary key (ID);
commit;

猜你喜欢

转载自mianhuaman.iteye.com/blog/1554341