zoukankan      html  css  js  c++  java
  • mysql练习02

    职工系统:

    设有关系职工表(职工号empno,职工名ename,部门号deptno,工资sal)和部门表(部门号deptno,部门名dname,主任manager),用SQL语句完成下列要求:

    create table emp (

    empno int(10) primary key,

    ename varchar(20),

    deptno int(10),

    sal decimal(10,2)

    );

    create table department (

    deptno int(10) primary key,

    dname varchar(20),

    manager varchar(20)

    );

    根据题目的关键字自行构建测试数据(比较重要)

      1)向职工表中插入行(‘025’,‘王芳’,‘03’,1000

    insert into emp values('025', '王芳', '03', '1000');

      2)从职工表中删除人事处的所有员工

    delete from emp where deptno = (select deptno from department where dname = '人事处');

      3)将职工号为‘001’的员工工资改为700元钱

    update emp set sal = '700' where empno = '001';

      4)查询人事处的员工最高工资

    select max(sal) from emp where deptno = (select deptno from department where dname = '人事处');

      5)查询“王芳”所在部门的部门主任

    select manager from department where deptno = (select deptno from emp where ename = '王芳');

    6)查询与“王芳”在同一部门的其它员工信息

    select * from emp where deptno = (select deptno from emp where ename = '王芳') and ename not like '王芳';

      7)建立公司所有部门的公共视图——部门职工视图

    create view dept_sta_view(empno, ename, deptno, sal, dname, mgr) as select a.empno, a.ename, a.deptno, a.sal, b.dname, b.manager from emp a, department b where a.deptno = b.deptno;

      8)从部门职工视图中查询财务处员工工资高于800元的员工信息

    select * from dept_sta_view where sal > '800' and dname = '财务处';

  • 相关阅读:
    手机号码正则(已测试可以)
    查看phpfpm的进程和端口号
    JS正则表达式验证是否为11位有效手机号码,
    访问HTML可以,访问PHPfile not found
    戏说论文、技术文档与网络文字的区别
    Sun 一线产品的图标
    VC编程中如何设置对话框的背景颜色和静态文本颜色
    Sun 一线产品的图标
    Web Beans首个预览版发布
    Web Beans首个预览版发布
  • 原文地址:https://www.cnblogs.com/assassin3154/p/7846390.html
Copyright © 2011-2022 走看看