Two foreign keys instead of primary

后端 未结 8 1624
陌清茗
陌清茗 2020-12-17 21:28

I was wondering, is there any possibility to create a table without a primary key, but with two foreign keys, where the foreign keys pairs are always different? For example,

8条回答
  •  误落风尘
    2020-12-17 22:04

    Like this:

    create table stock
    ( item_id      references items(item_id)
    , warehouse_id references warehouses(warehouse_id)
    , quantity     number(12,2) not null
    , constraint stock_pk primary key (item_id, warehouse_id)
    );
    

提交回复
热议问题