I have column in table book... named as status... i want to set default 1...
but, i tried DEFAULT 1,
ALTER TABLE book MODIFY status DEFAULT 1
and i insert new record... the record status is null
i tried to use Default on null 1
ALTER TABLE book MODIFY status DEFAULT ON NULL 1;
the output : ORA-00936: missing expression
what should i do? if i want the status value is default 1, not null when inserting new record
Your
ALTER TABLE book MODIFY status DEFAULT ON NULL 1;statement works (from Oracle 12.0.1 onwards):Then:
Outputs:
db<>fiddle here
If you are using a database version before 12.0.1 then, alternatively, you can use a trigger:
db<>fiddle here