xywuyiba7 发表于 2018-9-29 11:44:59

mysql建表-主键-索引-外键

    create table employees (
  id int(5) not null auto_increment ,
  name varchar(8) not null,
  primary key (id)
  )
  type=innodb;
  create table payroll(
  id int(5) not null,
  emp_id int(5) not null,
  name varchar(8) not null,
  payroll float(4,2) not null,
  primary key(id),
  index emp_id (emp_id),
  foreign key (emp_id) references employees (id)
  )
  type = innodb;
表间一对多关系示例:

页: [1]
查看完整版本: mysql建表-主键-索引-外键