📜  sql create table with references not primary key - SQL 代码示例

📅  最后修改于: 2022-03-11 15:05:34.180000             🧑  作者: Mango

代码示例1
CREATE TABLE Users(
  address varchar(100),
  phone_number varchar(20),
  userid serial,
  constraint pk primary key (address, phone_number ),
  constraint userid_unq unique (userid)
);

create table Stores(
  storeid int primary key,
  ownerID integer,
  constraint b_fk foreign key (ownerID)
    references Users(userid)
);