You are on page 1of 23

QUERIES

1. Create a table DEPT792 having attributes dno, dname, dhead, location (loc) with constraints: Primary key on dno using table constraint, Default on dhead, Check on loc, NotNull on dname.

Describe the structure of table DEPT792:-

RDBMS

2. Create table EMP792N with attributes empno, ename, deptno, job, hire_date, salary, commission, loc. Table constraints are: Primary key on empno, foreign key on deptno with DEPT table using table constraints, check on job, unique on ename, check on salary<5000.

Describe the structure of table EMP792N:

RDBMS

3. Delete the column loc from EMP792N table.

Describe the structure of EMP792N table:

RDBMS

4. Insert column mgr into table EMP792N.

Describe the structure of EMP792N table:

RDBMS

5. Delete UNIQUE constraint on ename of EMP792N table.

Table after deleting the UNIQUE constraint:

RDBMS

6. Create a table EMP_CT792 with same column definition as EMP792N table.

7. Drop table EMP_CT792.

RDBMS

8. Rename the table DEPT792 to DEPARTMENT792.

9. Add the following constraints to EMP792N table: Primary key on empno & Foreign key on deptno with department792

RDBMS

10. Insert at least 4 records in department792 table.

RDBMS

To see the table entries of department792 table:

11. Insert atleast 10 records in EMP792N table.

RDBMS

To see the table entries of EMP792N table:

12. Check the entire tables available in the section.

RDBMS

10

13. Show the column details of table EMP792N & DEPARTMENT792.

14. Show all the records in EMP792N table.

RDBMS

11

15. Show all the records in DEPTARTMENT792 table.

16. Show the ename, job, salary, and mgr from EMP792N table.

RDBMS

12

17. Show the ename, job and annual_salary from EMP792N table.

18. Show employees job in the following formatSmith works as clerk & give column aliases.

RDBMS

13

19. Show the email, job, mgr with manager Raj and Rajeev.

20. Show the email, job, mgr with manager Raj and Rajeev using IN clause.

RDBMS

14

21. Show ename, job, mgr who works in Deptno and salary>1000.

22. Show ename, job, mgr with salary between 1000 and 3000.

RDBMS

15

23. Show ename and job with job containing m from EMP792N table.

23. Show all records of the DEPARTMENT792 table ordered by location.

RDBMS

16

24. Show the records of employees which are not clerk.

25. Show ename, deptno and salary of employees. Then order the result by deptno and salary in descending order.

RDBMS

17

26. Display the employees working for less than 10 years and columns to be displayed are empno, hire_date, no of months employed with no decimal places, first Friday after the hire_date, last day of the month when he is employed.

27. Find the min, max and average salary of each department.

RDBMS

18

28. Change the deptno of employees with salary less than 3000.

29. Find the total no of employees in a particular department.

RDBMS

19

30. Find ename, salary, deptno of employees having same deptno as smith.

31. Find ename, salary, deptno of employees having same job as smith and salary greater than 2000.

RDBMS

20

QUERIES ON JOINS
1. Find ename, salary, job and dname of employees using equijoin.

2. Find ename, salary, job, and dname of employees using natural join.

RDBMS

21

3. Find ename, salary, job and dname of employees using left outer join.

4. Find ename, job, salary and dname of employees using right outer join.

RDBMS

22

5. Find ename, salary, job and dname of employees using ON clause.

6. Find ename, salary, job and dname of employees having salary>2000 using joins.

RDBMS

23

You might also like