Forum Stats

  • 3,734,282 Users
  • 2,246,937 Discussions


Disabling default constraint in a table is possible?

Lokesh A
Lokesh A Member Posts: 10 Red Ribbon

create table orders


order_id varchar2(10) primary key,

prod_id varchar2(10),

  order_date date,

  QTY integer default 1


In orders table i want to disable the default constraint value, but i am not able to drop the constraint as well. Right now I used alter statement. like this ALTER TABLE orders MODIFY qty DEFAULT NULL;

Is any possibility to drop or disable the default constraint in oracle?


  • Gaz in Oz
    Gaz in Oz Member Posts: 3,776 Bronze Crown

    The "DEFAULT" expression is not classed as a constraint. You have the correct syntax with "ALTER TABLE..."

  • Paulzip
    Paulzip Member Posts: 8,322 Blue Diamond
    edited Nov 17, 2020 3:04PM

    A constraint applies specific rules to data, ensuring the data conforms to the requirements defined.  A column default, like your QTY default provides a default value to a column when an INSERT does not provide a specific value to QTY. If you don't want a value for it, specify null :

    insert into orders(order_id, prod_id, order_date, qty)
    values (1, 1, sysdate, null);

    ..or remove the default :

    alter table orders modify qty default null;

Sign In or Register to comment.