文章出處
文章列表
如果表中有數據,Oracle是不能修改其數據類型的。但可以通過新建一個臨時列,將要修改列的數據復制到臨時列中,刪除原列再修改臨時列的名字。這樣說好像有點拗口,分步解說一下。
表AC_REG中有列:is_active,原來是字符類型的,目標是將它改為數值類型
---目標將IS_ACTIVE改為數值型 --新增一列 alter table AC_REG add is_active_temp number(1); --將IS_ACTIVE的值,賦給is_active_temp update AC_REG set is_active_temp = cast(is_active as number(1)); --刪除原來的列 alter table AC_REG drop column is_active; --修改名稱 alter table AC_REG rename column is_active_temp to is_active;
文章列表
全站熱搜