ORA-01439: column to be modified must be empty to change datatype

简介: 修改数据库字段类型,但是由于数据表已经存在数据,无法修改; 显示错误:ORA-01439: column to be modified must be empty to chang...

修改数据库字段类型,但是由于数据表已经存在数据,无法修改;

 

显示错误: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;


目录
相关文章
Cannot read properties of undefined (reading ‘row‘)
Cannot read properties of undefined (reading ‘row‘)
|
关系型数据库 MySQL 数据库
View ‘information_schema.SCHEMATA‘ references invalid table(s) or column(s) or function(s) or define
View ‘information_schema.SCHEMATA‘ references invalid table(s) or column(s) or function(s) or define
251 0
|
数据库
Data truncation: Incorrect date value: ‘2022-11-28T16:00:00.000Z‘ for column ‘start_date‘ at row 1
Data truncation: Incorrect date value: ‘2022-11-28T16:00:00.000Z‘ for column ‘start_date‘ at row 1
278 0
|
数据库
Incorrect table definition; there can be only one auto column and it must be defined as a key
Incorrect table definition; there can be only one auto column and it must be defined as a key
185 0
Incorrect table definition; there can be only one auto column and it must be defined as a key
|
编解码 搜索推荐 算法
Data-Data Objects and Attribute Types| 学习笔记
快速学习 Data-Data Objects and Attribute Types。
Data-Data Objects and Attribute Types| 学习笔记
|
关系型数据库 MySQL
报错:Incorrect datetime value: '0000-00-00 00:00:00' for column 'login_time' at row 1
报错:Incorrect datetime value: '0000-00-00 00:00:00' for column 'login_time' at row 1
674 0
|
SQL 关系型数据库 MySQL
Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT
Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT
|
SQL
ORA-01440: column to be modified must be empty to decrease precision or scale
在修改表字段的NUMBER类型的精度或刻度时,你可能会遇到ORA-01440: column to be modified must be empty to decrease precision or scale,下面介绍一下,如何处理这个问题。
1612 0
|
SQL
ORA-02292: integrity constraint (xxxx) violated - child record found
在更新表的主键字段或DELETE数据时,如果遇到ORA-02292: integrity constraint (xxxx) violated - child record found 这个是因为主外键关系,下面借助一个小列子来描述一下这个错误: SQL> create table studen...
2418 0
|
关系型数据库 MySQL
1293 - Incorrect table definition; there can be only oneTIMESTAMP column with CURRENT_TIMESTAMP
一个表中出现多个timestamp并设置其中一个为current_timestamp的时候经常会遇到 1293 - Incorrect table definition; there can be only oneTIME...
2485 0