I am using Toad Data Modeler 5.2.4.25 and I am trying to generate a DDL script for my Oracle 11g R2 database. I have the following related settings:
- In the settings of the primary key I have defined the name of the index as foo_pk_idx
- In the Order of Generated Objects I have keys set to “After CREATE TABLE section”
- In the settings for generating DDL, under the “What to Generate” tab, the Extended Value for Entities/Keys is set to “Drop and Create All Keys” and Entities/Indexes is set to Drop and Create.
Toad Data Modeler is currently generating something like:
CREATE TABLE foo(
foo_col1_pk Integer NOT NULL,
foo_col2 Varchar(10) NOT NULL,
foo_col3 Varchar(20)
)
/
CREATE UNIQUE INDEX foo_uk1 ON foo (foo_col2) --this is a unique key that is not the primary key
/
ALTER TABLE foo ADD CONSTRAINT foo_pk PRIMARY KEY (foo_col1_pk)
USING INDEX foo_col1_pk_idx
/
I receive an error “SQL Error: ORA-01418: specified index does not exist” because the script does not generate the primary key index before the primary key constraint. Ideally I would like Toad to generate the primary key as:
ALTER TABLE foo ADD CONSTRAINT foo_pk PRIMARY KEY (foo_col1_pk)
USING INDEX
/
This would automatically name the index for me as foo_col1_pk. However, i would be fine if it would just include the index DDL for the primary key index. Could someone suggest how to do either?