0% found this document useful (0 votes)
24 views4 pages

Assignmen1 RDBMS

Uploaded by

ibukalu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views4 pages

Assignmen1 RDBMS

Uploaded by

ibukalu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

C.B.

PATEL COMPUTER COLLEGE


Concepts Of RDBMS

Practical Assignment

Create DEPT and EMP with the following structures with appropriate
constraints.

dept(deptno,dname,location)
emp(empno,ename,job,mgrno,hiredate,sal,comm,deptno)

Constraints on tables :
Primary key : dept(deptno)
Primary key : emp(empno)
Foreign key : emp(deptno) (referential integrity)

Enter records in DEPT as given below.


DEPTNO DNAME LOC
------ -------------- --------------------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON

Enter records in EMP as given below


EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
------- ---------- --------- --------- --------- --------- --------- ----------------------------------------------
7369 SMITH CLERK 7902 17-DEC-80 800 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7788 SCOTT ANALYST 7566 19-APR-87 3000 20
7839 KING PRESIDENT 17-NOV-81 5000 10
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7876 ADAMS CLERK 7788 23-MAY-87 1100 20
7900 JAMES CLERK 7698 03-DEC-81 950 30
7902 FORD ANALYST 7566 03-DEC-81 3000 20
7934 MILLER CLERK 7782 23-JAN-82 1300 10
CREATE dept table.

CREATE TABLE dept(


deptno NUMBER(2,0) PRIMARY KEY,
dname VARCHAR2(14),
loc VARCHAR2(13));

Insert following records in dept table.


INSERT INTO dept VALUES(10, 'ACCOUNTING', 'NEW YORK');
INSERT INTO dept VALUES(20, 'RESEARCH', 'DALLAS');
INSERT INTO dept VALUES(30, 'SALES', 'CHICAGO');
INSERT INTO dept VALUES(40, 'OPERATIONS', 'BOSTON');

CREATE emp table.


CREATE TABLE emp(
empno NUMBER(4,0) PRIMARY KEY,
ename VARCHAR2(10),
job VARCHAR2(9),
mgr NUMBER(4,0),
hiredate DATE,
sal NUMBER(7,2),
comm NUMBER(7,2),
deptno NUMBER(2,0) REFERENCES dept (deptno));

Insert following records in emp table.


INSERT INTO emp VALUES (7369,'SMITH','CLERK',7902,'17-DEC-80',800,NULL,20);
INSERT INTO emp VALUES (7499,'ALLEN','SALESMAN',7698,'20-FEB-81',1600,300,30);
INSERT INTO emp VALUES (7521,'WARD','SALESMAN',7698,'22-FEB-81',1250,500,30);
INSERT INTO emp VALUES (7566,'JONES','MANAGER',7839,'02-APR-81',2975,NULL,20);
INSERT INTO emp VALUES (7654,'MARTIN','SALESMAN',7698,'28-SEP-81',1250,1400,30);
INSERT INTO emp VALUES (7698,'BLAKE','MANAGER',7839,'01-MAY-81',2850,NULL,30);
INSERT INTO emp VALUES (7782,'CLARK','MANAGER',7839,'09-JUN-81',2450,NULL,10);
INSERT INTO emp VALUES (7788,'SCOTT','ANALYST',7566,'19-APR-87',3000,NULL,20);
INSERT INTO emp VALUES (7839,'KING','PRESIDENT',NULL,'17-NOV-81',5000,NULL,10);
INSERT INTO emp VALUES (7844,'TURNER','SALESMAN',7698,'08-SEP-81',1500,0,30);
INSERT INTO emp VALUES (7876,'ADAMS','CLERK',7788,'23-MAY-87',1100,NULL,20);
INSERT INTO emp VALUES (7900,'JAMES','CLERK',7698,'03-DEC-81',950,NULL,30);
INSERT INTO emp VALUES (7902,'FORD','ANALYST',7566,'03-DEC-81',3000,NULL,20);
INSERT INTO emp VALUES (7934,'MILLER','CLERK',7782,'23-JAN-82',1300,NULL,10);
Solve the following queries.

(1) List all information about the employees in the EMP table.
(2) List all information about the departments in DEPT TABLE.
(3) List the employee number, name, job title, hire date of employees in
department 10.
(4) Select the name and salary of all employees who are clerks.
(5) List the name, job title and salary of everyone hired in year 1993.
(6) List the department number and name for departments with numbers
greater than or equal to 20.
(7) List the names of employees whose salaries are less than 3000.
(8) Select the name, salary and commission of employees whose commission
is greater than their salary.
(9) List the names and employee numbers of managers who earn more than
5000. Display in alphabetic order by name.
(10) Select information about managers and the president from the table EMP.
Order the result by department number.
(11) List the employees names that do not end in S.
(12) List the name, job and department of everyone whose name falls in the
alphabetic range “C” to “E”.
(13) List employee details working in department 20,30,40
(14) List of employees whose names start with T and ends with R.
(15) List of employees who do not get any commission.
(16) List the names and hire dates of the employees in department 20. Display
the hire date formatted as ‘12/05/93’.
(17) How many months has the president worked for the company ? Round to
the nearest whole number of months.
(18) List the names of employees whose hiredate is in the month of December.
(19) Display the name, monthly salary, yearly salary for all employees.
(20) Retrieve the analyst record with the hiredate formatted as the 3rd of
December, 2008.
(21) List the names of the employees whose hiredate is in the month of
December and year 1981 .
(22) List all employees names , jobs and a job classification.
Job classification : 1 for clerk, 2 for manager, ........
(23) Give SQL command to find the average annual salary per job in each
department.
(24) In on query, count the number of people in department 30 who receive
a salary and the number of people who receive a commission.
(25) Compute the average, minimum, maximum salaries of those group of
employees having the job of clerk or manager.
(26) Display the department number of departments which have more than one
clerk.
(27) Calculate the total compensation expense for each department for one
year.
(28) What is the length of the longest employee name?
(29) Which employees earns less than 30% of the president's salary?
(30) List the employees whose names are the longest.
(31) Who was the last employee hired in each department.
(32) How many employees work in New York?
(33) Which employees work in New York?
(34) List the employees names and cities in which they work, order the list by
city
(35) Find the number of different employees and number of departments.
(36) Determine the average salaries of employees.
(37) Find all employees working in department 10 other than king.
(38) List department number, department name, location and total commission
paid and total salary of each departments

You might also like