员工表
-- 员工表
CREATE TABLE emp (
id INT PRIMARY KEY, -- 员工id
ename VARCHAR(50), -- 员工姓名
job_id INT, -- 职务id
mgr INT , -- 上级领导
joindate DATE, -- 入职日期
salary DECIMAL(7,2), -- 工资
bonus DECIMAL(7,2), -- 奖金
dept_id INT, -- 所在部门编号
CONSTRAINT emp_jobid_ref_job_id_fk FOREIGN KEY (job_id) REFERENCES job (id),
CONSTRAINT emp_deptid_ref_dept_id_fk FOREIGN KEY (dept_id) REFERENCES dept (id)
);
-- 添加员工
INSERT INTO emp(id,ename,job_id,mgr,joindate,salary,bonus,dept_id) VALUES
(1001,'孙悟空',4,1004,'2018-12-17','8000.00',NULL,20),
(1002,'卢俊义',3,1006,'2011-02-20','16000.00','3000.00',30),
(1003,'林冲',3,1006,'2019-02-22','12500.00','5000.00',30),
(1004,'唐僧',2,1009,'2018-04-02','29750.00',NULL,20),
(1005,'李逵',4,1006,'2019-09-28','12500.00','14000.00',30),
(1006,'宋江',2,1009,'2018-5-01','28500.00',NULL,30),
(1007,'刘备',2,1009,'2017-09-01','24500.00',NULL,10),
(1008,'猪八戒',4,1004,'2012-04-19','30000.00',NULL,20),
(1009,'罗贯中',1,NULL,'2016-11-17','50000.00',NULL,10),
(1010,'吴用',3,1006,'2018-09-08','15000.00','0.00',30),
(1011,'沙僧',4,1004,'2009-05-23','11000.00',NULL,20),
(1012,'李逵',4,1006,'2007-12-03','9500.00',NULL,30),
(1013,'小白龙',4,1004,'2005-12-03','30000.00',NULL,20),
(1014,'关羽',4,1007,'2018-01-23','13000.00',NULL,10);
-- 工资等级表
CREATE TABLE salarygrade (
grade INT PRIMARY KEY, -- 级别
losalary INT, -- 最低工资
hisalary INT -- 最高工资
);
-- 添加5个工资等级
INSERT INTO salarygrade(grade,losalary,hisalary) VALUES
(1,7000,12000),
(2,12010,14000),
(3,14010,20000),
(4,20010,30000),
(5,30010,99990);