小编Ben*_*Ben的帖子

如何在一个create table语句中使用Index创建外键?(Oracle)的

我尝试使用外键约束创建一个新表(tableB)到另一个表(tableA),只是想知道我是否可以创建所需的所有约束和索引.我的目标是有一个单独的create table声明,alter table…之后不需要声明,也没有其他create index…声明.这可能吗?感谢您提前提示:)

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)
                       )
);
Run Code Online (Sandbox Code Playgroud)

sql oracle

4
推荐指数
1
解决办法
3021
查看次数

标签 统计

oracle ×1

sql ×1