0% found this document useful (0 votes)
88 views6 pages

Dbms

Uploaded by

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

Dbms

Uploaded by

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

roll no.

10060

1.create the EMP and DEPT tables with appropriate constraints by using query.
create table dep

(d_no number primary key,

e_name text);

create table emp

(e_no number primary key,

e_name text,

commission number,

salary number,

hir_date date,

d_no number references dep(d_no) );

2.inseart at leaste 30 records in EMP table and 5 records in DEPT table by using query.
INSERT INTO dep

VALUES (11, 'bhargav');

INSERT INTO emp

VALUES (1, 'bhargav', 40000, 35000, #6/5/1999#, 101);

3. display all the records of EMP table.

Select * from emp;

4. display all the records of DEPT table.

Select * from dep;

5. add one more coloumn commission into EMP table.

pg. 1
roll no. 10060
alter table emp

add coloumn commission text(40);

6. modify the size of name field by size text(40).


alter table emp

alter e_name text(40);

7. drop the temp field from EMP table.


alter table emp

drop column temp;

8. list all the employees who are working in dept no 5.


SELECT *

FROM emp

WHERE d_no=105;

9. list the name ,empno and department of all clerks.


SELECT e_name, e_no, d_name

FROM emp, dep

WHERE emp.d_no=dep.d_no and job like 'clark';

10. find the employees whose commission is greter than their salary.
SELECT *

FROM emp

WHERE commission>salary;

11. find the employees whose commission is greter than 40% of their salary.
SELECT *

FROM emp

WHERE commission>salary*(40/100);

pg. 2
roll no. 10060
12. find the employees whose commission is less than 40% of their salary.
SELECT *

FROM emp

WHERE commission<=salary*(40/100);

13. find all salesman in department 30 whose salary is gretar than or equal to rs 1500.
SELECT *

FROM emp

WHERE d_no=103 and salary>=1500;

14. find all employees whose designation is either ‘manager’ or ‘president’.


SELECT *

FROM emp

WHERE job like 'manager' or job like 'president';

15. find all manager who are not in department 30.


SELECT *

FROM emp

WHERE job Like 'manager' And d_no<>103;

16.find all detail of all ‘manager’ in department no 10 and ‘clark’.

SELECT *

FROM emp

WHERE (job like 'manager' and d_no=101) or job like 'clark';

17. find the detail of all ‘manager’ (work in any department) and

SELECT *

FROM emp

WHERE job like 'manager' or (job like 'clark' and d_no=102);


pg. 3
roll no. 10060
18.find the name of employe in deptno 20 who is neither a manager not a clark.

SELECT *

FROM emp

WHERE d_no=102 And (job<>'manager' Or job<>'clark');

19. find the employees who does not received commission.

SELECT *

FROM emp

WHERE comission=0;

20. find the employe whose name begning letter ‘m’ and end with ‘n’.

SELECT *

FROM emp

WHERE e_name like 'M*n';

21. find the employee whose name are five character long and ends with ‘a’.

SELECT *

FROM emp

WHERE e_name like '????a';

22. find the all employee who have hired in the month February of any year.

Select * from emp

Where format(hir_date,’mn’)=2;

23. show the first five character of all employee.

Select left(name,5)

AS emp_name from emp;

24. for each employee display the no of month passed since the employee join the company.

Select emp_no, name,datedif(‘m’,hirdate,now)

From emp;

pg. 4
roll no. 10060
25.display the name of employee shorted their names.

SELECT *

FROM emp

ORDER BY e_name;

26. display the name , job and salary of all employee shorted on job and salary in descending order.

SELECT e_name, job, salary

FROM emp

ORDER BY job DESC , salary DESC;

27. increase the salary of employee by 10%

UPDATE emp SET salary = salary+(salary*10/100);

28. delete of recorde of president.

DELETE *

FROM emp

WHERE job like 'president';

29. give the commission rs 500 to all employee whose salary less than rs 5000.

UPDATE emp SET commission = 500

WHERE salary<5000;

30. find the detail employee who getting higest salary.

SELECT *

FROM emp

WHERE salary >= (select max(salary) from emp);

31. find the average salary of manager.

SELECT *

FROM emp

WHERE job like 'manager';

pg. 5
roll no. 10060
32. list the total no of employee in company.

SELECT count(e_no)

FROM emp;

33. find the detail of employe who are working in a/c department and sett higher salary.

Select * from emp

where salary=(select max(salary)from emp

where dep_no=(select dep_no from dep

where dep_name=’account’)) and dep_no=(dep_no from dep

where dep_name=’account’);

34. list all employe whose hier date is 1/jan/1999.

SELECT *

FROM emp

WHERE hir_date=#1/1/1999#;

35. list the name , job, salary of emp in department who earn more than rs 5000.

SELECT e_no, e_name, job, salary

FROM emp

WHERE salary>=5000;

pg. 6

You might also like