在oracle中更改数据类型而不删除数据 [英] Changing data type in oracle without deleting the data

查看:219
本文介绍了在oracle中更改数据类型而不删除数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Product Version Oracle 10g

我在oracle中有一个表,其中有一些数据.有一列类型为Number(10,0)的列.现在我想将其更改为Number(10,2)以允许小数.但是要更改,oracle不允许不删除现有数据. 我知道我可以备份数据->删除数据->更改类型->插入数据. 但是问题是有一个自动插入列,该列从序列中获取值. 因此,当我将其重新插入时,这些ID会发生变化....我不确定是否有人使用该ID作为获取数据的键.因此,如何在不更改ID的情况下进行更改.

I have a table in oracle with some data in it. There is a column which of type Number(10,0). Now i want to change it to Number(10,2) to allow decimals. But to change, oracle is not allowing without deleting the existing data. I know i can take the data backup -> delete data -> change type -> insert data back. But the problem is there is an auto insert column which gets value from a sequence. So when i insert it back those id will change....I am not sure that if anyone is using that id as a key to get the data. So how can i change it without altering the ids..

请帮助.

推荐答案

可能您希望number(12,2)保持精度. 例如,number(7,2)是一个在小数点前5位和小数点后2位的数字.

Probably you want number(12,2) to keep precision. For example, number(7,2) is a number that has 5 digits before the decimal and 2 digits after the decimal.

或者,您可以禁用触发器/执行工作/启用触发器.

Alternately, you may disable the trigger / do the work / enable the trigger.

这篇关于在oracle中更改数据类型而不删除数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆