Subject | A unique index which is not? |
---|---|
Author | Avi Schwartz |
Post date | 2004-09-17T21:05:24Z |
I have this strange problem. I have two tables which I am trying to
create a foreign key relationship between them. However, even though I
create the unique index before attempting to create the FK relationship
it fails claiming that the unique index cannot be found. Any idea what
may the problem be? This is 1.5.1 on Linux.
SQL> show table repl_type;
REPL_TYPE_ID INTEGER Not Null
REPL_TYPE_NAME VARCHAR(50) CHARACTER SET NONE Nullable
REPL_TYPE_DESC VARCHAR(100) CHARACTER SET NONE Nullable
REPL_TYPE_CODE VARCHAR(8) CHARACTER SET NONE Not Null
DATE_ADDED TIMESTAMP Not Null default current_timestamp
DATE_DELETED TIMESTAMP Nullable
CONSTRAINT PK__REPL_TYPE__25276EE5:
Primary key (REPL_TYPE_ID)
SQL> show table configured_selection;
CONFIGURED_SELECTION_ID INTEGER Not Null
...
REPL_TYPE_CODE VARCHAR(8) CHARACTER SET NONE Nullable
...
CONSTRAINT R_4:
Foreign key (SELECTION_ID) References SELECTION (SELECTION_ID)
CONSTRAINT PK__CONFIGURED_SELEC__1FCDBCEB:
Primary key (CONFIGURED_SELECTION_ID)
Triggers on Table CONFIGURED_SELECTION:
TRIG_CONFIGURED_SELECTION_BI, Sequence: 0, Type: BEFORE INSERT, Active
SQL> CREATE UNIQUE INDEX unique_val ON repl_type (repl_type_code);
SQL> show index unique_val;
UNIQUE_VAL UNIQUE INDEX ON REPL_TYPE(REPL_TYPE_CODE)
SQL> ALTER TABLE configured_selection ADD CONSTRAINT
FK__configure__repl___233F2673 FOREIGN KEY (repl_type_code) REFERENCES
repl_type (repl_type_code);
Statement failed, SQLCODE = -607
unsuccessful metadata update
-could not find UNIQUE INDEX with specified columns
SQL> show index unique_val;
UNIQUE_VAL UNIQUE INDEX ON REPL_TYPE(REPL_TYPE_CODE)
Thanks,
Avi
create a foreign key relationship between them. However, even though I
create the unique index before attempting to create the FK relationship
it fails claiming that the unique index cannot be found. Any idea what
may the problem be? This is 1.5.1 on Linux.
SQL> show table repl_type;
REPL_TYPE_ID INTEGER Not Null
REPL_TYPE_NAME VARCHAR(50) CHARACTER SET NONE Nullable
REPL_TYPE_DESC VARCHAR(100) CHARACTER SET NONE Nullable
REPL_TYPE_CODE VARCHAR(8) CHARACTER SET NONE Not Null
DATE_ADDED TIMESTAMP Not Null default current_timestamp
DATE_DELETED TIMESTAMP Nullable
CONSTRAINT PK__REPL_TYPE__25276EE5:
Primary key (REPL_TYPE_ID)
SQL> show table configured_selection;
CONFIGURED_SELECTION_ID INTEGER Not Null
...
REPL_TYPE_CODE VARCHAR(8) CHARACTER SET NONE Nullable
...
CONSTRAINT R_4:
Foreign key (SELECTION_ID) References SELECTION (SELECTION_ID)
CONSTRAINT PK__CONFIGURED_SELEC__1FCDBCEB:
Primary key (CONFIGURED_SELECTION_ID)
Triggers on Table CONFIGURED_SELECTION:
TRIG_CONFIGURED_SELECTION_BI, Sequence: 0, Type: BEFORE INSERT, Active
SQL> CREATE UNIQUE INDEX unique_val ON repl_type (repl_type_code);
SQL> show index unique_val;
UNIQUE_VAL UNIQUE INDEX ON REPL_TYPE(REPL_TYPE_CODE)
SQL> ALTER TABLE configured_selection ADD CONSTRAINT
FK__configure__repl___233F2673 FOREIGN KEY (repl_type_code) REFERENCES
repl_type (repl_type_code);
Statement failed, SQLCODE = -607
unsuccessful metadata update
-could not find UNIQUE INDEX with specified columns
SQL> show index unique_val;
UNIQUE_VAL UNIQUE INDEX ON REPL_TYPE(REPL_TYPE_CODE)
Thanks,
Avi