0% found this document useful (0 votes)
62 views12 pages

Dbms Lab: Experiment

1. The document describes experiments conducted in a database management systems lab. 2. It involves creating an EMPLOYEE table with various columns like EMPNO, ENAME, JOB, etc and inserting sample data. 3. A series of 17 queries are then performed on the table like selecting records between salary ranges, finding minimum/maximum salaries, modifying records etc.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
62 views12 pages

Dbms Lab: Experiment

1. The document describes experiments conducted in a database management systems lab. 2. It involves creating an EMPLOYEE table with various columns like EMPNO, ENAME, JOB, etc and inserting sample data. 3. A series of 17 queries are then performed on the table like selecting records between salary ranges, finding minimum/maximum salaries, modifying records etc.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 12

DBMS LAB

Submission by:-
Anand Kumar
(19UICS008/1911291)

Experiment NO.3

 Create a Database called EMPLOYEE_Your Roll Number.


 Create a Table called emp with following columns.
EMPNO INT
ENAME VARCHAR (10)
JOB VARCHAR (9)
MGR INT
HIREDATE VARCHAR(9)
SAL INT
COMM INT
DEPTNO INT
AGE INT
ESAL INT

Query :-
CREATE TABLE Emp( EMPNO INT, ENAME VARCHAR(10), JOB
VARCHAR(9), MGR INT, HIREDATE VARCHAR(9), SAL INT, COMM INT,
DEPTNO INT, AGE INT, ESAL INT );

Result :

 Insert the following data into the emp table.


Query :-
INSERT INTO emp VALUES
(7369,'SMITH','CLERK',7902,'17-DEC-80',800,0,20,25,0),
(7499,'ALLEN','SALESMAN',7698,'20-FEB-81',1600,300,30,25,0),
(7521,'WARD','SALESMAN',7698,'22-FEB-81',1250,500,30,25,0),
(7566,'JONES','MANAGER',7839,'02-APR-81',2975,500,20,25,0),
(7698,'KE','MANAGER',7839,'01-MAY-81',2850,1400,30,25,0);

Result :
Q. No.1 :- List all employee names and their salaries, whose salary lies between
1500/- and 3500/- both inclusive.
Query :- SELECT ENAME, SAL FROM emp WHERE SAL BETWEEN 1500 AND 3500;
Result:-

Q.No.2 :- List all employee names and their and their manager whose manager is
7902 or 7566 or 7789.
Query :-
SELECT ENAME, MGR FROM emp WHERE (MGR = 7902) OR(MGR = 7566) OR(MGR = 7789);

Result:-
Q.No.3 :- List all employees, which starts with either J or T.

Query :- SELECT * FROM emp WHERE ENAME LIKE 'J%' OR ENAME LIKE 'T%';
Result:-

Q.No.4 :- List all employee names and jobs, whose job title includes M or P. Query
:- SELECT ENAME, JOB FROM emp WHERE JOB LIKE '%M%' OR JOB LIKE '%P%';
Result:-
Q.No.5 :- List all jobs available in employee table.

Query :- SELECT DISTINCT JOB FROM emp;

Result:-

Q.No.6 :-List all employees who belongs to the department 10 or 20.

Query :- SELECT * FROM emp WHERE DEPTNO IN(10, 20);
Result:-
Q.No.7:-List all employee names, salary and 15% rise in salary.

Query :- SELECT ENAME, SAL, 1.15 * SAL AS 'RAISE' FROM emp;

Result:-

Q.No.8:-List minimum, maximum, average salaries of employee.

Query :-
SELECT MIN(SAL) AS 'MIN', MAX(SAL) AS 'MAX', AVG(SAL) AS 'AVG' FROM emp;

Result:-
Q.No.9:-Find how many job titles are available in employee table.

Query :- SELECT COUNT(DISTINCT JOB) FROM emp;

Result:-

Q.No.10:-Find how much amount the company is spending towards salaries.

Query :- SELECT SUM(SAL) FROM emp;
Result:-
Q.No.11:-Display name of the dept. with dept no 20.

Query :-
SELECT ENAME FROM emp WHERE DEPTNO = 20;SELECT ENAME FROM emp WHERE DEPTNO = 20;

Result:-

Q.No.12:-List ENAME whose commission is NULL.

Query :- SELECT ENAME FROM emp WHERE COMM = NULL;
Result:-
Q.No.13:-Find no.of dept in employee table.

Query :- SELECT COUNT(DISTINCT DEPTNO) FROM emp;

Result:-

Q.No.14:-List ENAME whose manager is not NULL.

Query :- SELECT ENAME FROM emp WHERE MGR = NULL;
Result:-
Q.No.15:-Change the AGE to 30 whose JOB is MANAGER.

Query :- UPDATE emp SET AGE = 30 WHERE JOB = 'manager';
Result:-

Q.No.16:-Modify ESAL to 20000/- whose MGR is 7698.

Query :- UPDATE emp SET ESAL = 20000 WHERE MGR = 7698;
Result:-
Q.No.17:-Delete the record whose HIREDATE is 01-MAY-81.

Query :- DELETE FROM emp WHERE HIREDATE ='01-MAY-81';
Result:-

You might also like