i am trying to create Unique Constraint of table oms_product_group's Column product_group_name.
it's parent child relationship like parent_id will be same for some the product_group_name
Example:
product_group_name parent_id
-----------------------------------------------
All 0
Mobile 1
Laptop 1
Men 2
Men 2 (<--- if i have already created MEN then it must not allow me create it again)
Android 3
What i have tried.
alter table OMS_PRODUCT_GROUP add constraint OMS_PRODUCT_GROUP_NAME_UN unique (PRODUCT_GROUP_NAME) DEFERRABLE INITIALLY IMMEDIATE;
ERROR: ORA-02299: cannot validate (ECUBE.OMS_PRODUCT_GROUP_NAME_UN) - duplicate keys found
alter table OMS_PRODUCT_GROUP add novalidate constraint OMS_PRODUCT_GROUP_NAME_UN
using index (create index unique_index on OMS_PRODUCT_GROUP(PRODUCT_GROUP_NAME));
ORA-02253: constraint specification not allowed here
So basically if some one inserted one value name he/she can not insert same value name again that's i am creating Unique Key Constraints.
Thank You
Pranav Shah.