0% found this document useful (0 votes)
27 views

SQL Assignment 2

The document contains 58 questions related to performing various SQL queries and DML operations on database tables. The tables created are employee, department, and location to store information. Questions involve creating the tables, inserting data, updating, deleting rows, modifying columns, joining tables, aggregating data, sorting results and more. The goal is to practice common SQL statements and learn to manage data in relational database tables.

Uploaded by

5597PRIYANSHU
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

SQL Assignment 2

The document contains 58 questions related to performing various SQL queries and DML operations on database tables. The tables created are employee, department, and location to store information. Questions involve creating the tables, inserting data, updating, deleting rows, modifying columns, joining tables, aggregating data, sorting results and more. The goal is to practice common SQL statements and learn to manage data in relational database tables.

Uploaded by

5597PRIYANSHU
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

DBMS Lab - Assignment 2

Q1: Create a new user making “your_name” as user-name and “your_surname” as the password.

Q2: Grant all privileges to the newly created user.

Q3: connect to the new user.

Q4: Create a table employee with attributes emp_id, f_name , l_name , job_type, salary, commision,
dept, and manager_id.

Q5: Describe the table employee

Q6: Add a new column doj to the employee table.

Q7: Create a new table department with attributes d_name, d_loc, and hod_id.

Q8: Create another table named location with attributes loc_id, city and contact_no.

Q9. Enhance the size of city attribute in location table by 5.

Q10. Delete the contact_no attribute in the location table.

Q11. Rename the city attribute in the location table to address.

Q12. Change the name of the table from location to loc.

Q13. Insert the following values into the loc table.

LOC_ID ADDRESS
1 kolkata
2 mumbai

Q14. Show the values of location table.

Q15. Delete all values and spaces consumed by loc table.

Q16. Delete the loc table.

Q17. Insert the following values into the department table.

D_Name D_LOC HOD_ID


sales Kol 4
accounts delhi 6
production kol 1
marketing kol 2
r&d delhi 8
Q18. Insert the following values into the employee table.

EMP_ID F_NAME L_NAME JOB_TYPE SALARY COMMISION DEPT MANAGER_ID DOJ


1 arun khan manager 90000 production 04-JAN-1998
2 barun kumar manager 80000 marketing 09-FEB-1998
3 chitra kapoor engineer 60000 production 1 08-JAN-1998
4 dheeraj mishra manager 75000 sales 2 27-DEC-2001
5 emma dutt engineer 55000 production 1 20-MAR-2002
6 floki dutt accountant 70000 accounts 16-JUL-2000
7 dheeraj kumar clerk 40000 accounts 6 01-JUL-2016
8 saul good engineer 60000 r&d 06-SEP-2014
9 mou bhat clerk 30000 sales 4 08-MAR-2018
10 sunny deol salesman 20000 10000 marketing 2 31-MAR-01
11 bobby deol engineer 35000 r&d 8 17-OCT-17
12 amir khan salesman 15000 5000 marketing 2 11-JAN-13

Q19. Save the database.

Q20: Show all the attribute values of the department table.

Q21: Display the department names and their locations.

Q22: Show the employee’s first name, last name, current salary and the salary with a 1000 rupees bonus.

Q23: Show the employee’s annual salary with a 1000 rupees yearly bonus and the annual salary with a
100 rupees monthly bonus.

Q24: Show f_name as Name and annual salary as ANNSAL from the employee table.

Q25: Show the L_name as SurName and 100 rupees incremented salary as NewSal from the employee
table.

Q26: Display the employees f_name and l_name joined together using the concatenation operator.

Q27: Show the f_name, l_name and job_type as Employees.

Q28: Show the employee details in the following fassion:

Employees Details

---------------------------------------------------------

arun khan is a manager

barun kumar is a manager

……..

……..
Q29: Show the monthly salary details in the following fassion:

Monthly Salary Details

--------------------------------------------------------------------------------

arun's monthly salary is 90000

………

Q30: Show the department names from the employee table.

Q31: Show the distinct department names from the employee table.

Q32: Show the employees earning more than 50000.

Q33. Show the employee’s id’s who are not working under manager id-1.

Q34: Show the employee’s names and salaries whose salary ranges between 40000 to 70000.

Q35: Show the employees who work for manager id 1 or 6 or 8.

Q36: Select the first names and salaries of those employee whose last name is khan.

Q37: Select the first names and salaries of those employee whose last name starts with k.

Q38: Select the first name, last name and salary of those employee whose last name starts with k and
ends with r.

Q39: Select the employees whose 3rd letter of their last name is o.

Q40: Select the employees who are not working under any manager.

Q41: Select the employees who work as engineers with salary greater than 50000.

Q42: Select the employees who work in the production department or earns more than 60000.

Q43: Select those employees who are not managers or engineers or clerks.

Q44: Select the employees who earns more than 49000 or less than 29000.

Q45. Select the employees who don’t have an ‘o’ as the 2nd last letter of their last name.

Q46. Select the employees who get commission.

Q47. WAQ to display the current date.

Q48. Show the total experience in weeks for all the employees.

Q49. Find the employees working under employee_id 2.

Q50. Delete the employees from sales department if they are not working as managers.

Q51. Insert the following two rows in the employee table without inserting any value in the department
field.
EMP_ID F_NAME L_NAME JOB_TYPE SALARY COMMISION D_NAME MANAGER_ID DOJ

13 anand patil engineer 28000 2000 1 31-JAN-17

14 anandi patel clerk 12000 500 1 01-APR-17

Q52. . Insert the following two rows in the department table.

D_NAME D_LOC HOD_ID

---------- ---------- ----------

Admin Mumbai 5

Transport Mumbai 3

Q53. Update the employee table. Assign Anand to the admin department.

Q54. Update the manager_id from 2 to 1 in the employee table.

Q55. Display the employee details in descending order on their salary.

Q56. Display the employee details in ascending order on their l_name.

Q57. Delete the employees who are working as salesmen and having less experience than 15 years.

Q58. Commit the database.

You might also like