Create constraint in alter table without checking existing data

后端 未结 3 968
梦如初夏
梦如初夏 2021-01-13 00:53

I\'m trying to create a constraint on the OE.PRODUCT_INFORMATION table which is delivered with Oracle 11g R2. The constraint should make the PRODUCT

3条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-13 01:16

    You can certainly create a constraint which will validate any newly inserted or updated records, but which will not be validated against old existing data, using the NOVALIDATE keyword, e.g.:

    ALTER TABLE PRODUCT_INFORMATION
      ADD CONSTRAINT PRINF_NAME_UNIQUE UNIQUE (PRODUCT_NAME)
      NOVALIDATE;
    

    If there is no index on the column, this command will create a non-unique index on the column.

提交回复
热议问题