zoukankan      html  css  js  c++  java
  • Oracle 部门员工查询

    
    
      1. --部门:部门编号,部门名称,地址;  
      2. --员工:员工编号,员工名字,职务,管理编号,入职日期,薪资,奖金,部门编号;
    CREATE TABLE dept(  
    deptno INT PRIMARY KEY,
    dname VARCHAR(20),
    loc VARCHAR(20)   
    );  
    CREATE TABLE emp(
    empno INT PRIMARY KEY,
    ename VARCHAR(20) NOT NULL,    
    job VARCHAR(20) CHECK (job IN('CLERK','SALESMAN','MANAGER','ANALYST')),
    mgp INT,  
    hiredate DATE ,
    sal DECIMAL(10,2),
    comm DECIMAL(10,2),  
    deptno INT,  
    CONSTRAINT pk_we FOREIGN KEY (deptno) REFERENCES dept (deptno)  
    )

    插入数据:

    INSERT INTO dept VALUES (10,'ACCOUNTING','NEWTORK');  
    INSERT INTO dept VALUES (20,'RESEARCH','DALLAS');  
    INSERT INTO dept VALUES (30,'SALES','CHICAGO');  
    INSERT INTO dept VALUES (40,'OPERATIONS','BOSTON');    
    select * from dept
    insert into emp values(7369,'SMITH','CLERK',7902,'1980-12-17',1640,NULL,20);
    insert into emp values(7499,'ALLEN','SALESMAN',7698,'1981-2-20',11400,300,30);
    insert into empvalues(7521,'WARD','SALESMAN',7698,'1981-2-22',5200,500,30);
    insert into empvalues(7566,'JOENS','MANAGER',7839,'1981-4-2',7015,NULL,20);
    insert into emp values(7654,'MARTIN','SALESMAN',7698,'1981-9-28',5200,1400,30);
    insert into empvalues(7698,'BLAKE','MANAGER',7839,'1981-5-1',5900,NULL,30);
    insert into empvalues(7782,'CLARK','MANAGER',7839,'1981-6-9',2470,NULL,10);
    insert into emp values(7788,'SCOTT','ANALYST',7566,'1987-4-19',3040,NULL,20);

      select a.ENAME  from  emp a
                 where exists(select * from  dept b where b.deptno=a.deptno and b.deptno=10);

  • 相关阅读:
    hdu 1754 I Hate It
    hdu 2546 饭卡
    hdu 4506 小明系列故事——师兄帮帮忙
    hdu 3665 Seaside
    hdu 3790 最短路径问题
    hdu 1869 六度分离
    最长递增字串的三种做法
    问题集???
    IOS开发学习 碎片S
    超级台阶 (NYOJ—76)
  • 原文地址:https://www.cnblogs.com/bulrush/p/7552683.html
Copyright © 2011-2022 走看看