ndash;新增臨時列 alter table tablename add filedname_temp number(2); ndash;將臨時列的值置空 update zyt set id_temp=nul
–新增臨時列
alter table tablename add filedname_temp number(2);
–將臨時列的值置空
update zyt set id_temp=null; -----#alter table tablename modify filedname null;
–將要更新的字段值挪到臨時列,并置空該列
update tablename set filedname_temp=filedname,filedname=null;
commit;
–修改列的數據類型為varchar2
alter table tablename modify filedname varchar2(20);
–將要臨時列值重新挪到該列,并置空臨時列
update tablename set filedname=filedname_temp,filedname_temp=null;
commit;
–刪除臨時列
alter table tablename drop column filedname_temp;
–給該列不能為空
alter table tablename modify filedname not null;
–執行查詢測試
select * from tablename ;
使用這種方式,既不用使列名發生變化,也不會發生表遷移,但有個缺點是表要更新兩次,而且當如果數據量較大時,,產生的undo和redo也更多,前提也是要停機才進行操作,如果不停機 ,也可以采用在線重定義方式來做。
注:請自行更換tablename和filedname為自己的實際值。
聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com