Forum Stats

  • 3,781,116 Users
  • 2,254,481 Discussions
  • 7,879,576 Comments

Discussions

Table DDL duplicates PK and unique index

147712
147712 Member Posts: 7
edited Nov 12, 2008 3:55PM in SQL Developer
I haven't seen anything specific to this in the forums, but I'm surprised that it hasn't been addressed (unless it's fat fingers on my part).

Generated DDL for a fairly simple table includes both an ALTER TABLE statement for primary key constraint, and a CREATE UNIQUE INDEX for the same constraint. Obviously, the index statement causes a "ORA-00955: Name is already used by an existing object" exception.

My understanding is that the alter statement implicitly creates a unique index, so there ought to be no need to explicitly create the index.

I've observed this behaviour in Sql Dev 1.2 and 1.5.

CREATE TABLE "DT_CALENDAR_WEEK"
...
ALTER TABLE "DT_CALENDAR_WEEK" ADD CONSTRAINT "DT_CALENDAR_WEEK_PK" PRIMARY KEY ("FSC_WK_NUM") ENABLE;

CREATE UNIQUE INDEX "DT_CALENDAR_WEEK_PK" ON "DT_CALENDAR_WEEK" ("FSC_WK_NUM") ;

Am I missing something here? Any constructive suggestions greatly appreciated.

Cheers,

Patrick

Answers

This discussion has been closed.