一对多SQL表创建
create table dept(id int auto_increment comment 'ID' primary key,name varchar(50) not null comment '部门名称'
) comment '部门表';
insert into dept (name) values ('研发部'),('市场部'),('财务部'),('销售部'),('总经办');
create table emp(id int auto_increment comment 'ID' primary key,name varchar(50) not null comment '姓名',age int comment '年龄',job varchar(20) comment '职位',salary int comment '薪资',entrydate date comment '入职时间',managerid int comment '直属领导ID',dept_id int comment '部门ID',constraint fk_emp_dept_id foreign key (dept_id) references dept(id)
)comment '员工表';
insert into emp (name,age,job,salary,entrydate,managerid,dept_id) values
('金庸',66,'总裁',20000,'2000-01-01',null,5),
('张无忌',20,'项目经理',12500,'2005-12-05',1,1),
('杨逍',33,'开发',8400,'2000-11-03',2,1),
('韦一笑',48,'开发',11000,'2002-02-05',2,1),
('常遇春',43,'开发',10500,'2004-09-07',3,1),
('小昭',19,'程序员鼓励师',6600,'2004-10-12',2,1),
('灭绝',60,'财务总监',8500,'2002-09-07',1,3),
('周芷若',19,'会计',48000,'2006-06-02',7,3),
('丁敏君',23,'出纳',5250,'2009-05-13',7,3),
('赵敏',20,'市场部总监',12500,'2004-10-12',1,2),
('鹿杖客',56,'职员',3750,'2006-10-03',10,2),
('鹤笔翁',19,'职员',3750,'2007-05-09',10,2),
('方东白',19,'职员',5500,'2009-02-12',10,2),
('张三丰',88,'销售总监',14000,'2004-10-12',1,4),
('俞莲舟',38