• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Unique constraint and index ?

 
Ranch Hand
Posts: 316
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In a table creation scrript I hvae

create or replace table EDITOR (
...
CONSTRAINT "EDITOR_UNIQUE" UNIQUE(NAME, COLUMN_NAME) ENABLE
..
)

I meant to make the combination of "NAME" and "COLUMN_NAME" be unique (neither of them is PK). In the DDL script I didn't add anything else. But it seems Oracle does not actually create such constraint for me as I can insert rows with such duplicated values. I don't know why. Somebody said I need to create a "index" for this constraint like

CREATE UNIQUE INDEX "EDITOR_UNIQUE" ON "EDITOR" ("NAME", "COLUMN_NAME")
/

what ? I thought this is not an index at all. Plus, to my understanding, if I have already such a "EDITOR_UNIQUE" constraint name, then the above "create unique index" syntax is not going to work as Oracle may complain the object ("EDITOR_UNIQUE") already exists..

anyway, I am confused. Hope someone can help me out on what I ought to do.

Thanks.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic