0

I'm not allowed to drop the table, or delete the columns. The task is to add a constraint to a column possibly by using an ALTER statement so that it disallows any negative numbers. Is this possible?

I tried the following:

SQL> alter table SPEND_PLAN_DETAIL_VALUE modify (SP_DETAIL_VALUE_ID CHECK (SP_DETAIL_VALUE_ID > 0));

but this doesn't work.

0

1 Answer 1

2

To add a constraint you need to use add constraint:

alter table SPEND_PLAN_DETAIL_VALUE 
  add constraint check_detailvalue CHECK (SP_DETAIL_VALUE_ID > 0);

Online example

0

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.