0% found this document useful (0 votes)
48 views2 pages

Exercise 1

The document outlines a set of SQL commands to create tables, insert data, alter tables, and perform queries on employee and department data. It includes commands to create tables with fields, add constraints like primary keys and foreign keys, insert sample data, perform CRUD operations, and run various selection queries on the data.
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)
48 views2 pages

Exercise 1

The document outlines a set of SQL commands to create tables, insert data, alter tables, and perform queries on employee and department data. It includes commands to create tables with fields, add constraints like primary keys and foreign keys, insert sample data, perform CRUD operations, and run various selection queries on the data.
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/ 2

1. Create a table Emp with the following fields.

Name Constraint Type


Empno Not null Number
Ename Not null Char
Job Not null Char
Unique
Mgr Number
Hiredate Not null Date
Sal Not null Number – real
Comm Number – real
Deptno Foreign key Number
Age Not null Number
Esal Number

2. Create a table Dept with the following fields.

Name Constraint Type


Deptno Not null Number
Primary key
Dname Not null Char
Loc Not null Char

3. Describe emp

4. Describe Dept.

5. Describe programmer.

6. Alter table by adding primary key for the attribute empno in Emp table.

7. Alter table by adding foreign key for the attribute mgr in the table Emp.

8. Practice drop command.

9. Insert 5 rows of data into each of the tables.

10. Practice delete and update commands.

11. Practice TCL commands.

(a) commit

(b) rollback

(c) savepoint

12. Practice string built-in functions.

13. Practice date built-in functions.


14. List all the employee details.

15. List all employee names and their salaries, whose salary lies between 1500/- and 3500/- both
inclusive.

16. List all employee names and their and their manager whose manager is 7902 or 7566 0r 7789.

17. List all employees which starts with either J or T.

18. List all employee names and jobs, whose job title includes M or P.

19. List all jobs available in employee table.

20. List all employees who belongs to the department 10 or 20.

21. List all employee names , salary and 15% rise in salary.

22. List minimum , maximum , average salaries of employee.

23. Find how many job titles are available in employee table.

24. What is the difference between maximum and minimum salaries of employees in the
organization?

25. Display all employee names and salary whose salary is greater than minimum salary of the
company and job title starts with ‘M’.

26. Find how much amount the company is spending towards salaries.

27. Display name of the dept. with deptno 20.

28. List ename whose commission is NULL.

29. Find no.of dept in employee table.

30. List ename whose manager is not NULL.

You might also like