您的位置:首页 > 数据库 > MySQL

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

2012-03-17 11:39 483 查看
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;
表间一对多关系示例:
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  职场 mysql 休闲