Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

sql create table with references not primary key

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)
);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #sql #create #table #references #primary #key
ADD COMMENT
Topic
Name
8+5 =