📜  sql 确保每个用户都是 unqiuew - SQL 代码示例

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

代码示例1
create table user(
    user_id  INT  auto_increment  PRIMARY KEY,
    username varchar(50) not null,
    avator  varchar(50),
    gender  boolean not null,
    phone varchar(20),
    unique(username)
);

create table journey(
    id INT auto_increment PRIMARY KEY,
    start varchar(100) not null,
    dest varchar(100) not null,
    time date not null,
    person INT,
    user_id INT not null,
    foreign key(user_id) references user(user_id)
);