甲骨文| ORA-01439: 要修改的列必须为空才能更改数据类型。无法在 oracle 10g 中将数据类型编号更改为 nvarchar
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28025582/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Oracle | ORA-01439: column to be modified must be empty to change datatype. Unable to alter datatype number to nvarchar In oracle 10g
提问by Simple Doe
I want it without data deleting and moving.
我想要它没有数据删除和移动。
I am Unable to alter datatype number to nvarchar In oracle 10g. its displaying message like ORA-01439: column to be modified must be empty to change datatype.
我无法在 oracle 10g 中将数据类型编号更改为 nvarchar。其显示消息如 ORA-01439:要修改的列必须为空才能更改数据类型。
I have data in table and column is already set NOT NUll so i cannot set it null or blank. And Altering column is primary key which is related number of tables to foreign key.
我在表中有数据,列已经设置为 NOT NULL,所以我不能将其设置为 null 或空白。并且改变列是主键,它是与外键相关的表数。
Is there any quick solution to Fix it.
是否有任何快速解决方案来修复它。
回答by pringi
Suggested way:
建议方式:
- Suspend constraints
- Create another column with nvarchar type
- Copy from number column to the new nvarchar column
- Delete number column
- Rename nvarchar column to the old one
- Rebuild indexes
- Activate constraints.
- 暂停约束
- 创建另一个 nvarchar 类型的列
- 从数字列复制到新的 nvarchar 列
- 删除数字列
- 将 nvarchar 列重命名为旧列
- 重建索引
- 激活约束。
You cannot change a column type in oracle other way (that i know about).
您不能以其他方式(我知道)在 oracle 中更改列类型。
回答by Lalit Kumar B
- Add the new column with a new name.
- Update the new column from old column.
- Drop the old column.
- Rename the new column with the old column name.
- 添加具有新名称的新列。
- 从旧列更新新列。
- 删除旧列。
- 用旧列名重命名新列。
NOTEI see you have also mentioned Oracle 11gtag, however your question says you are on 10g. If you are on 11g or up, you could use VIRTUAL COLUMN.
注意我看到您还提到了Oracle 11g标签,但是您的问题说您使用的是 10g。如果您使用 11g 或更高版本,则可以使用VIRTUAL COLUMN。