Using Druid to generate SQL script for Oracle, I have seen a difference between the version 3.10 and 3.13 and I would like to understand what going on.
SQL generated by Druid 3.10 :
CREATE TABLE ATTRIBUTE_VALUE_LABEL
(
ID NUMBER(18),
ATTRVALID NUMBER(18) not null,
LANGUAGE NVARCHAR2(2) not null,
NAME NVARCHAR2(250) not null,
CREATED DATE default SYSDATE,
MODIFIED DATE,
CONSTRAINT PK_ATTRIBUTE_VALUE_LABEL primary key(ID) USING INDEX TABLESPACE &&TSINDEX,
CONSTRAINT XA_ATTRIBUTE_VALUE_LABEL_2 unique(ATTRVALID,LANGUAGE) USING INDEX TABLESPACE &&TSINDEX,
CONSTRAINT FK_ATTRIBUTE_VALUE_LABEL_1 foreign key(ATTRVALID) references ATTRIBUTE_VALUE(ID) on delete CASCADE
);
SQL generated by Druid 3.13 :
CREATE TABLE ATTRIBUTE_VALUE_LABEL
(
ID NUMBER(18),
ATTRVALID NUMBER(18) not null,
LANGUAGE NVARCHAR2(2) not null,
NAME NVARCHAR2(250) not null,
CREATED DATE default SYSDATE,
MODIFIED DATE,
CONSTRAINT PK_ATTRIBUTE_VALUE_LABEL primary key(ID) USING INDEX TABLESPACE &&TSINDEX,
CONSTRAINT XA_ATTRIBUTE_VALUE_LABEL_2 unique(ATTRVALID,LANGUAGE),
CONSTRAINT FK_ATTRIBUTE_VALUE_LABEL_1 foreign key(ATTRVALID) references ATTRIBUTE_VALUE(ID) on delete CASCADE
);
As you can see, the only difference is that Druid don't generate anymore a USING INDEX TABLESPACE &&TSINDEX
after the UNIQUE
constraint.
I suspect that there is a reason for why Druid don't generate anymore this USING INDEX
thing on the UNIQUE
constraint (could have something to do with the fact that there already a USING INDEX
on the PRIMARY
constraint), but I would like to understand why.
I have two questions then :
- Can this cause some error on Oracle ?
- Do this change something for the index used by the unique constraint ? Not in the right table space ?
Best Answer
If the
USING INDEX
clause is omitted, the index will be still created automatically with the same name as the constraint, in the same tablespace where table is created. This will not cause an error.http://docs.oracle.com/database/121/SQLRF/clauses002.htm#SQLRF52225