Question: In Oracle, is there a way to remove the default of the column of a table ?
In Oracle, I created a table with nn columns.
In one of the columns I defined a default value.
Now the default value is not valid anymore.
I would like to keep the column but remove the default.
Is there a way to remove the default of the column of a table ?
The following is an example of my question:
create table test (
t2 number default 0
insert into test(t1,t2) values (1,1);
insert into test(t1) values (2);
-- The following does not work to remove the default
alter table test modify (
t2 number) ;
insert into test(t1) values (3);
Any ideas besides dropping and recreating the column ?
alter table test modify t2 default null;
"False data can act only as a distraction. Therefore. I shall refuse to perceive you." - Bomb #20
tomcat got there right before me
He's right, only way is to change the default is to modify it to null (acts the same as if you didn't have it to begin with). And, in case you want it, here is the link to the oracle doc which states:
If a column has a default value, then you can use the DEFAULT clause to change the default to NULL, but you cannot remove the default value completely. That is, if a column has ever had a default value assigned to it, then the DATA_DEFAULT column of the USER_TAB_COLUMNS data dictionary view will always display either a default value or NULL."
(search for data_default on this page):
Click Here to Expand Forum to Full Width