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;
表间一对多关系示例:
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的几个概念:主键,外键,索引,唯一索引
- MySQL的几个概念:主键,外键,索引,唯一索引
- MySQL的几个概念:主键,外键,索引,唯一索引
- mysql建表-主键-索引-外键
- MySQL主键,外键,索引,唯一索引
- MySQL的几个概念:主键,外键,索引,唯一索引
- mysql建表-主键-索引-外键
- 【MySQL】数据类型&时间戳&主键&外键&索引
- MySQL的几个概念:主键,外键,索引,唯一索引
- MySQL的几个概念:主键,外键,索引,唯一索引
- mysql表的主键、外键、限定、约定、索引、视同、存储过程
- MySQL的几个概念:主键,外键,索引,唯一索引
- mysql 主键,外键,唯一键,索引的区别
- MySQL之主键、外键、索引
- 【Mysql】主键,外键,索引,唯一索引
- mysql主键,外键,索引
- mysql的主键外键索引的区别
- MySQL的几个概念:主键,外键,索引,唯一索引
- mysql主键,外键,索引
- MySQL添加/删除主键、外键、唯一键、索引、自增