Worksheet SQL and Connectivity
Worksheet SQL and Connectivity
Worksheet SQL and Connectivity
Q1) Given the details for the table EMPLOYEE , write the queries for the following problems: -
Fk Table Department
Fk column DeptId
length 6 20 30 10 9,2 2
a) Create the table EMPLOYEE on the basis of the above information with all constraints.
b) Add a new column Gender to the table EMPLOYEE with datatype as Varchar and size
c) Delete the entire table EMPLOYEE from the database
d) To open the database named MYDB
Q2) Rahul, working in ABC Infotech Pvt. Ltd. needs to store, retrieve and delete the records of its employees,
developed an interface that provides front-end interaction through Python, and stores and updates records in
EMPLOYEE table. Help Rahul to write code for performing following functionality in his program.
user=root host=localhost Datadase=MYDB password=1234
(a) to read all the records from EMP table having salary more than 70000.
(b) to update the records of employees by increasing salary by 1000 of all those employees who are getting
less than 80000.
(c) Program to delete the record on the basis of inputted empno.
Q3. A) Rahul working on table employee given in Q no. 4, added age and city of all employees in table. Then
after two employees AMIR and SCOTT resigned their jobs. Now, help Rahul to find out the degree and
cardinality of the employee table.
DEPARTMENT
QUERY
i) Insert a new record to the table EMPLOYEE with the details :-
(101,”MANAV”,”KOLKATA”,912345678, 50000, 10)
ii) To increase the Salary by 5% for all CLERKS
iii) Display Ename,sal,deptno who are not getting commission from table emp.
iv) List the details of employees who earn more commission than their salaries.
v) Display employee number, name, Salary, 5% Increased Salary of all employees
vi) How many job types are offered to employees.
vii) List the details of all employees whose salary is between 2500 and 3500.
viii)Write a query to delete all those records whose hiredate is after ‘01-01-1992’.
ix) To display the name of the employees whose name contains ‘A’ as third letter.
x) Display a report of employee table with all records sorted in descending order.
xi) To display Name of employee with respective Department name of employee who are getting salary
more than 20000.
xii) Write the UPDATE command to increase the commission by 500 of all the employees working in sales
department getting salary less than 10000.
xiii)Write a query to find job wise average salary.
xiv)Display the name of employees working in the department having more than 3 employees.
xv) Find the minimum, maximum salary for every job with number of employees in that job.