--1.创建部门表
create table dept
(
deptno int(2) unsigned primary key,
dname varchar(14),
loc varchar(13)
);
--2.添加部门数据
insert into dept(deptno,dname,loc) values
(10,'ACCOUNTING','NEW YORK'),
(20,'RESEARCH','DALLAS'),
(30,'SALES','CHICAGO'),
(40,'OPERATIONS','BOSTON');
--3.创建员工表
create table emp
(
empno int(4) unsigned primary key,
ename varchar(10),
job varchar(9),
mgr int(4),
hiredate date,
sal double(7,2),
comm double(7,2),
deptno int(2) references dept(deptno)
);
--4.插入数据员工数据
insert into emp(empno,ename,job,mgr,hiredate,sal,comm,deptno) values
(7369,'SMITH','CLERK',7902,'1980-12-17',800,null,20),
(7499,'ALLEN','SALESMAN',7698,'1981-02-20',1600,300,30),
(7521,'WARD','SALESMAN',7698,'1981-02-22',1250,500,30),
(7566,'JONES','MANAGER',7839,'1981-04-02',2975,null,20),
(7654,'MARTIN','SALESMAN',7698,'1981-09-28',1250,1400,30),
(7698,'BLAKE','MANAGER',7839,'1981-05-01',2850,null,30),
(7782,'BLAKE','MANAGER',7839,'1981-06-09',2450,null,10),
(7788,'SCOTT','ANALYST',7566,'1987-04-19',3000,null,20),
(7839,'KING','PRESIDENT',null,'1981-11-17',5000,null,10),
(7844,'TURNER','SALESMAN',7698,'1981-09-08',1500,0,30),
(7876,'ADAMS','CLERK',7788,'1987-05-23',1100,null,20),
(7900,'JAMES','CLERK',7698,'1981-12-03',950,null,30),
(7902,'FORD','ANALYST',7566,'1981-12-03',3000,null,20),
(7934,'MILLER','CLERK',7782,'1982-01-23',1300,null,10);
--5.员工福利表
create table bonus
(
ename varchar(10),
job varchar(9),
sal double(7,2),
comm double(7,2)
);
--6.工资等级表
create table salgrade
(
grade int(10),
losal double(7,2),
hisal double(7,2)
);
--7.插入工资等级信息
insert into salgrade(grade,losal,hisal) values
(1,700,1200),
(2,1201,1400),
(3,1401,2000),
(4,2001,3000),
(5,3001,9999);
8.提交事务
commit;
标签:10,20,1981,--,30,构建,mysql,soctt,null From: https://www.cnblogs.com/holly8/p/18219890