-- 建立数据库
create database ch_5;
-- 链接数据库
use ch_5;
-- 新建数据表dept
create table dept
(
d_no int primary key auto_increment,
d_name varchar(50) not null,
d_location varchar(100)
)engine=InnoDB;
-- 新建数据表employee
create table employee
(
e_no int primary key,
e_name varchar(100) not null,
e_gender char(2),
dept_no int not null,
e_job varchar(100)not null,
e_salary smallint not null,
hiredate date not null,
constraint fk_employee_dept foreign key(dept_no) references dept(d_no)
)engine=InnoDB;
-- 插入数据
insert into dept values(10,'ACCOUNTING','ShangHai');
insert into dept values(20,'RESEATCH','BeiJing');
insert into dept values(30,'SALES','ShenZhen');
insert into dept values(40,'OPERATIONS','FuJian');
insert into employee values(1001,'SMITH','m',20,'CLERK',800,'2005-11-12');
insert into employee values(1002,