ORA-01439: column to be modified must be empty to change datatype
2014-06-11 10:37
399 查看
修改数据库字段类型,但是由于数据表已经存在数据,无法修改;
显示错误:ORA-01439: column to be modified must be empty to change datatype
alter table USERS add tmp_col NUMBER(1);-- 添加临时列
update USERS set tmp_col = CUSTOMER_MARITAL_STATUS ; --将目标字段中数据加入到临时列中
update USERS set CUSTOMER_MARITAL_STATUS = null; --将目标字段数据清空
alter table USERS modify ( CUSTOMER_MARITAL_STATUS NUMBER(1)); --更改目标字段类型
update USERS set CUSTOMER_MARITAL_STATUS = tmp_col; --将临时列数据加回到目标字段中
alter table USERS drop column tmp_col; --清除临时列
SELECT DISTINCT CUSTOMER_MARITAL_STATUS FROM USERS;
SELECT DISTINCT tmp_col FROM USERS;
显示错误:ORA-01439: column to be modified must be empty to change datatype
alter table USERS add tmp_col NUMBER(1);-- 添加临时列
update USERS set tmp_col = CUSTOMER_MARITAL_STATUS ; --将目标字段中数据加入到临时列中
update USERS set CUSTOMER_MARITAL_STATUS = null; --将目标字段数据清空
alter table USERS modify ( CUSTOMER_MARITAL_STATUS NUMBER(1)); --更改目标字段类型
update USERS set CUSTOMER_MARITAL_STATUS = tmp_col; --将临时列数据加回到目标字段中
alter table USERS drop column tmp_col; --清除临时列
SELECT DISTINCT CUSTOMER_MARITAL_STATUS FROM USERS;
SELECT DISTINCT tmp_col FROM USERS;
相关文章推荐
- ORA-01439: column to be modified must be empty to change datatype
- ORA-01439: column to be modified must be empty to change datatype
- ora-01440:column to be modified must be empty to decrease precision or scale
- ORA-01440: column to be modified must be empty to decrease precision or scale
- 修改表字段,column to be modified must be empty
- ORA-01758: table must be empty to add mandatory (NOT NULL) column
- ORA-01442: column to be modified to NOT NULL is already NOT NULL
- ORA-01442: column to be modified to NOT NULL is already NOT NULL
- Thread: alter varchar2 column to clob // ORA-22858: invalid alteration of datatype
- ORA-54033要修改的列由某个虚拟表达式使用column to be modified is used in a virtual column expression
- oracle : olumn to be modified must be empty to decrease precision or scale
- Oracle exp EXP-00008 和ORA-01455: converting column overflows integer datatype 的解决方法
- Attribute "column" must be declared for element type "property"解决办法
- OnCheckChangeListener cannot be resolved to a type
- According to TLD, tag s:property must be empty
- 关于:ORA-02069: global_names parameter must be set to TRUE for this operation
- 异常:According to TLD tag beanwrite must be empty but is not
- ORA-02069: global_names parameter must be set to TRUE for this operation
- A SELECT statement that assigns a value to a variable must not be combined with data-retrieval opera
- VS2010:error C3083: 'Windows': the symbol to the left of a '::' must be a type