1

I want to set a NOT NULL column to nullable AND also set default value to NULL

I have tried:

alter table T_FUNCIO modify (VALIDATED NULL DEFAULT NULL);
alter table T_FUNCIO modify VALIDATED NULL DEFAULT NULL;

but none of the 2 works

3 Answers 3

2

You have the clauses the wrong way around. From the syntax diagrams, the DEFAULT ... clause comes before the inline constraint. So you can do:

alter table T_FUNCIO modify VALIDATED DEFAULT NULL NULL;

Note though that if the column is already nullable, which is the default if you didn't specify it at table creation (as is the default value being null of course), then this will still throw "ORA-01451: column to be modified to NULL cannot be modified to NULL". You said your column is currently NOT NULL though, so this should be fine.

Quick db<>fiddle demo.

Sign up to request clarification or add additional context in comments.

Comments

1

you can try this

ALTER TABLE T_FUNCIO
MODIFY VALIDATED int DEFAULT NULL

1 Comment

This doesn't remove the NOT NULL constraint? (Also restating the data type isn't necessary...)
0

The syntax is a little counter-intuitive:

alter table T_FUNCIO modify (VALIDATED NULL)

Here is a db<>fiddle.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.