方法一:
// 創建一樣的臨時表
create table T_BUSINESS_MODEL_TEMP as select * from T_BUSINESS_MODEL where 1=2 ;
// 對臨時表改數據類型alter table T_BUSINESS_MODEL_TEMP modify MODEL_MONEY NUMBER(10,2);
// 將原表數據賦值到最新的表中
insert into T_BUSINESS_MODEL_TEMP select * from T_BUSINESS_MODEL;
// 刪掉原來的表
drop table T_BUSINESS_MODEL;
// 將臨時表重新命名為原表
alter table T_BUSINESS_MODEL_TEMP rename to T_BUSINESS_MODEL;
// 添加原表的約束 (主鍵,外鍵,索引)
alter table T_BUSINESS_MODEL
add constraint PK_T_BUSINESS_MODEL primary key (ID);
方法二:
-- 字段重命名
alter table PROJECT rename column NAME to NAME1;
----- 把字段名稱改成原來的名稱
alter table PROJECT add NAME VARCHAR2(300);
--- 賦值
update PROJECT np
set np.name=np.name1;
commit;
--- 刪掉原來重命名的字段
alter table PROJECT drop column NAME1;
個人覺得還是方法二比較好一些!