在oracle中更新列的数据类型 [英] update data type of a column in oracle

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

问题描述

我正在使用此查询进行更新:它显示错误无效的变更表选项:

1:ALTER TABLE MENU."MNU_TASK"修改TASK_ID编号不为空AUTO_INCREMENT

2:ALTER TABLE MENU.MNU_TASK修改TASK_ID编号不为空AUTO_INCREMENT

都不能正常工作

解决方案

我找到了Oracle的解决方法,因为它似乎不支持每个关键字: http: //www.lifeaftercoffee.com/2006/02/17/how-to-create-auto-increment-columns-in-oracle/ [
因此,请确保您有任何此类问题,在这种情况下,您可以执行以下操作,

1.您已经手动更新了现有表,其中TASK_ID为NULL的地方写了一些值.因此,现在TASK_ID列中包含一些值,您可以更改表.

2.您必须再次创建您的表,现在您必须在其中指定约束条件,即TASK_ID列为Not Null ...

3.拖放现有表并新建一个表.


i am using this query for updation : It shows the error Invalid alter table option:

1 : ALTER TABLE MENU."MNU_TASK" MODIFY TASK_ID NUMBER NOT NULL AUTO_INCREMENT

2 : ALTER TABLE MENU.MNU_TASK MODIFY TASK_ID NUMBER NOT NULL AUTO_INCREMENT

both not working

thanks in advance.

I found a workaround for Oracle as it does not seem to support it per keyword: http://jen.fluxcapacitor.net/geek/autoincr.html[^].
Or try here it seems to be analogous: http://www.lifeaftercoffee.com/2006/02/17/how-to-create-auto-increment-columns-in-oracle/[^].

Best Regards,

-MRB


It should be in the following format:

alter table 
   table_name
modify 
( 
   column_name    data_type
);



In your case, you forgot the round brackets.


Yes it might be the case if you have already declare TASK_ID Column as NULL and you have some values in your table which contains TASK_ID as NULL and now you are trying to add "Not Null" Constrained on values those are already NULL.

So please be sure if you have any such issue then in this case you can do following things,

1. You have manually update your existing Table Where You have Write Some Values where TASK_ID is NULL.So that now TASK_ID Column contains Some value and You can Alter Your Table.

2.You have to Again create your Table in which now you have to specify your constrained i.e TASK_ID Column as Not Null...

3.Drope Your existing Table and Make a New one.


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

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