主页 > 知识库 > MySQL版oracle下scott用户建表语句实例

MySQL版oracle下scott用户建表语句实例

热门标签:Linux服务器 地方门户网站 百度竞价排名 AI电销 网站排名优化 铁路电话系统 服务外包 呼叫中心市场需求

概述:

Oracle scott用户下四张表,比较便于做实验,验证数据,现修改为MySQL版本

1.部门表 --dept

2.员工表 --emp

3.工资等级表 --salgrade

4.奖金表 --bonus

dept

-- Create table
create table DEPT
(
 deptno INT(2) not null,
 dname VARCHAR(14),
 loc VARCHAR(13)
) engine=InnoDB charset=utf8; 
-- Create/Recreate primary, unique and foreign key constraints 
alter table DEPT
 add constraint PK_DEPT primary key (DEPTNO)
;
insert into DEPT(DEPTNO, DNAME, LOC)
values ('10', 'ACCOUNTING', 'NEW YORK');

insert into DEPT(DEPTNO, DNAME, LOC)
values ('20', 'RESEARCH', 'DALLAS');

insert into DEPT(DEPTNO, DNAME, LOC)
values ('30', 'SALES', 'CHICAGO');

insert into DEPT(DEPTNO, DNAME, LOC)
values ('40', 'OPERATIONS', 'BOSTON');

emp

-- Create table
create table EMP
(
 empno INT(4) not null,
 ename VARCHAR(10),
 job  VARCHAR(9),
 mgr  INT(4),
 hiredate DATE,
 sal  decimal(7,2),
 comm  decimal(7,2),
 deptno INT(2)
) engine=InnoDB charset=utf8;
-- Create/Recreate primary, unique and foreign key constraints 
alter table EMP
 add constraint PK_EMP primary key (EMPNO);
alter table EMP
 add constraint FK_DEPTNO foreign key (DEPTNO)
 references DEPT (DEPTNO);
insert into EMP(EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO)
values ('7369', 'SMITH', 'CLERK', '7902','1980-12-17', '800', null, '20');

insert into EMP(EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO)
values ('7499', 'ALLEN', 'SALESMAN', '7698', '1981-02-20', '1600', '300', '30');

insert into EMP(EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO)
values ('7521', 'WARD', 'SALESMAN', '7698', '1981-02-22', '1250', '500', '30');

insert into EMP(EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO)
values ('7566', 'JONES', 'MANAGER', '7839', '1981-04-02', '2975', null, '20');

insert into EMP(EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO)
values ('7654', 'MARTIN', 'SALESMAN', '7698', '1981-09-28', '1250', '1400', '30');

insert into EMP(EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO)
values ('7698', 'BLAKE', 'MANAGER', '7839', '1981-05-01', '2850', null, '30');

insert into EMP(EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO)
values ('7782', 'CLARK', 'MANAGER', '7839', '1981-06-09', '2450', null, '10');

insert into EMP(EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO)
values ('7788', 'SCOTT', 'ANALYST', '7566', '1987-06-13', '3000', null, '20');

insert into EMP(EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO)
values ('7839', 'KING', 'PRESIDENT', null, '1981-11-17', '5000', null, '10');

insert into EMP(EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO)
values ('7844', 'TURNER', 'SALESMAN', '7698', '1981-09-08', '1500', '0', '30');

insert into EMP(EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO)
values ('7876', 'ADAMS', 'CLERK', '7788', '1987-06-13', '1100', null, '20');

insert into EMP(EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO)
values ('7900', 'JAMES', 'CLERK', '7698', '1981-12-03', '950', null, '30');

insert into EMP(EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO)
values ('7902', 'FORD', 'ANALYST', '7566', '1981-12-03', '3000', null, '20');

insert into EMP(EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO)
values ('7934', 'MILLER', 'CLERK', '7782', '1982-01-23', '1300', null, '10');

salgrade

create table SALGRADE
(
 grade INT,
 losal INT,
 hisal INT
) engine=InnoDB charset=utf8;
insert into SALGRADE(GRADE, LOSAL, HISAL)
values ('1', '700', '1200');

insert into SALGRADE(GRADE, LOSAL, HISAL)
values ('2', '1201', '1400');

insert into SALGRADE(GRADE, LOSAL, HISAL)
values ('3', '1401', '2000');

insert into SALGRADE(GRADE, LOSAL, HISAL)
values ('4', '2001', '3000');

insert into SALGRADE(GRADE, LOSAL, HISAL)
values ('5', '3001', '9999');

bonus

create table BONUS
(
 ename VARCHAR(10),
 job VARCHAR(9),
 sal INT,
 comm INT
) engine=InnoDB charset=utf8 ;

总结

到此这篇关于MySQL版oracle下scott用户建表语句的文章就介绍到这了,更多相关MySQL版oracle scott用户建表内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

您可能感兴趣的文章:
  • 详解Mysql和Oracle之间的误区
  • SpringBoot多数据库连接(mysql+oracle)的实现
  • 详解MySQL实时同步到Oracle解决方案
  • mysql、oracle默认事务隔离级别的说明
  • MyBatis JdbcType 与Oracle、MySql数据类型对应关系说明
  • mysql和oracle的区别小结(功能性能、选择、使用它们时的sql等对比)
  • mysql类似oracle rownum写法实例详解
  • 浅谈Mysql、SqlServer、Oracle三大数据库的区别
  • Oracle更换为MySQL遇到的问题及解决

标签:崇左 兰州 湘潭 湖南 衡水 仙桃 黄山 铜川

巨人网络通讯声明:本文标题《MySQL版oracle下scott用户建表语句实例》,本文关键词  ;如发现本文内容存在版权问题,烦请提供相关信息告之我们,我们将及时沟通与处理。本站内容系统采集于网络,涉及言论、版权与本站无关。
  • 相关文章
  • 收缩
    • 微信客服
    • 微信二维码
    • 电话咨询

    • 400-1100-266