如何在Oracle中将number(7,2)更改为varchar? [英] How to change number(7,2) to varchar in oracle?
问题描述
我正在使用Oracle 10g.我想将#附加到"sal"列中的所有值.为了先完成此操作,我尝试将"sal"列的数据类型从数字更改为varchar,但出现以下错误
I'm using Oracle 10g. I want to append # to all values in 'sal' column. To acomplish this first I'm trying to change data type of 'sal' column from numeric to varchar but getting following error
我在做什么错了?
推荐答案
您应使用modify
关键字,而不要使用第二个alter
.
You should use modify
keyword instead of your second alter
.
alter table
emp
modify
(
sal varchar2(10)
);
修改表列数据类型时,需要使用modify
关键字.
When modifying a tables column datatype , you need to use modify
keyword.
当然,您必须处理现有的列数据.修改表列数据类型时,您可能需要导出行,重新定义表,然后重新导入数据.
Of course, you must deal with existing column data. When modifying a tables column datatype you may want to export the rows, redefine the table and then re-import you data.
在这种情况下,您需要按照以下步骤更改列数据类型:
In this you would need to follow these steps to alter a column data type:
- 在表末尾创建新列.
- 运行更新以填充新表列
- 删除旧表列
- 将新列重命名为原始列名
这篇关于如何在Oracle中将number(7,2)更改为varchar?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!