How to create a foreign key with an index in one table declaration? (Oracle)

I tried to create a new table (tableB) with a foreign key binding to another table (tableA) and just wondering if I can create all the necessary constraints and indexes with it. My goal would be to have one statement create tablewithout the need for an instruction alter table…after this and no other instruction create index…. Is it possible? Thanks for any hint in advance :)

create table tableA
(
   id number
 , constraint tableApk primary key (id)
);

create table tableB
(
   id number
 , constraint tableBfk foreign key (id) references tableA (id)
                       on delete cascade
                       using index (
                         create index tableBfkidx on tableB (id)
                       )
);
+4
source share
1 answer

It is unacceptable. In the documentation, using_index_clause can only be specified for unique or primary constraints.

Good luck.

+6

Source: https://habr.com/ru/post/1628490/


All Articles