Oracle Department Employee inquiries

Source: Internet
Author: User

      1. -Department: Department number, department name, address;
      2. --Employees: Employee number, employee name, job title, management number, entry date, salary, bonus, department number;
CREATE TABLE Dept (  deptno INT PRIMARY key,dname varchar (), loc VARCHAR)   ;  CREATE TABLE emp (empno INT PRIMARY key,ename VARCHAR () not NULL,    job VARCHARCHECK (' 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 data:

INSERT into Dept VALUES (' ACCOUNTING ', ' newtork '); INSERT into Dept VALUES (' DALLAS ', ' the '); INSERT into Dept VALUES (' SALES ', ' CHICAGO '); INSERT into Dept VALUES (Max, ' OPERATIONS ', ' BOSTON '); Select*From Deptinsert 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);

Oracle Department Employee inquiries

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.