Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2004

    Question Unanswered: how to add a constraint name to a column

    I created a table

    create table table1(
    id number(8,2) constraint table1_pk primary key,
    price not null);

    now I want to add a constraint name(table1_price_nn) to price, I used

    alter table table1 add constraint table1_price_nn (price);

    It gave me an error message. Anyone knows how to add the constraint name to it? Note: In my sistuation, the table can not be recreated but modify.

  2. #2
    Join Date
    Nov 2003

    Re: how to add a constraint name to a column

    What constraint you want to add. You haven't specified that.

    "alter table table1 add constraint table1_price_nn (price);" ... This statement doesn't mean anything. Because you are not adding any constraint.
    For eg.
    If you want to check a column FLAGE to be T or F ..... then

    ADD ( CONSTRAINT check_upper CHECK (UPPER(FLAG) IN ('T', 'F')) ) ;

  3. #3
    Join Date
    Jan 2004
    Croatia, Europe
    Provided Answers: 5
    Is this what you're looking for?

    ALTER TABLE table1
    MODIFY price
    CONSTRAINT table1_price_nn NOT NULL;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts