Uploaded by sidcreatorcool

Lab 1

advertisement
DBMS Lab Exercise-1
Name: N Siddarth Chandrasekar
Registration Number: 21BAI1195
1. Create student table with the attributes SName, RegNo, Dept, Mobile, Place, M1, M2, M3:
2. Display the structure of the student table:
3. Rename the Mobile attribute as MobileNo:
4. Modify the table by removing Place attribute
5. Insert 5 rows into student table:
Two ways:
And
6. Display the student table with all attributes
7. Display only student names
8. Modify the table by adding Tot, Avg and Status:
9. Update the table by calculating Tot, Avg and Status • Tot=M1+M2+M3 • Avg=Tot/3 • Status
= “Eligible” if Avg >=50, “Not Eligible” if Avg <50:
10.Display the Regno, Sname, Tot, Avg and Status of the students:
11.Display the students’ details where Tot > 200:
12.Display the eligible students’ details
13.Delete a row from student table where SName=’Ram’:
14.Create faculty table with the attributes Faculty_ID, Name and Salary:
15.Insert Any 2 rows into faculty table:
16.Display the faculty table with attributes:
17.Display faculty table where Faculty_ID=121:
18.Display all available tables in your user login:
19.Delete all the values from faculty table
20.Drop faculty table:
DBMS Lab Exercise-2
Name: N Siddarth Chandrasekar
Registration Number: 21BAI1195
1. Consider the database for an organization and create the following tables.
o department (dept_no, dept_name, location).
o employee (emp_no PRIMARY KEY, emp_name NOT NULL, DOB, address, doj, mobile_no, dept_no
references department(dept_no), salary number(9,2), check(). Write the queries for the following 1.
Add necessary constraints to the tables • (Primary key, NOT NULL, check (salary>50,000), foreign
key)
2. Modify the employee table by adding designation attribute
Ans)
3. Delete the address attribute from employee table
4. Add 5 rows in the employee and department tables Date format(‘dd/mon/yyyy’ eg ‘01/jan/2023’)
Validate the entries by entering
(a)duplicate dept_no – department table
(b) duplicate emp_no – employee table
(c)null value for emp_name – employee table
(d) salary 25000 – employee table
(e)new dept_no value in employee table (dept_no should not be available in department table)
Adding 5 Rows into department and employee:
Validating the entries:
(a) Duplicate dept_no in department table:
(b) duplicate emp_no – employee table
(c)null value for emp_name – employee table
(d) salary 25000 – employee table
(e)new dept_no value in employee table (dept_no should not be available in department table)
5. Display all the records from employee and department tables
6. Display the emp_no and emp_name of all the employees from department no ‘d02’
7. Display the mobile number of ‘John’
8. Delete the employee record whose mobile_no=9999955555
9. Update the salary with 10% hike
10. Display the empno and name of all employees whose salary is between 60000 and 70000
11. Display emp_no, emp_name, designation, dept_no and salary in the descending order of salary
12. Display emp_no, emp_name, designation, dept_no and salary in the ascending order of salary
DBMS Lab Exercise-3
Name: N Siddarth Chandrasekar
Registration Number: 21BAI1195
1.Display all designations without duplicate values.(adddesignation in employee table and update the
values –use alter, update, select with distinct)
Inserting a distinct entry:
Selecting distinct values:
2.Display the dept_no and total salary of employees of each department.(use select with sum and
group by)
3.Change the salary of employees to 25000 whose designation is ‘Typist’(use update)
Inserting a few typists:
Changing the salary to 51000 instead as there is a constraint that prevents salary less than 50000:
4.Change the mobile no of employee named ‘John’(use update)
5.Delete the record of the employee with emp-no 121(use delete)
6.Delete all employees whose salaries are equal to Rs.70000(use delete)
7.Update the salary by 1.25 times for all employees who work in research department.
8. Find the Name and Salary of people who draw in the range Rs. 50,000 to Rs. 90,000.(Useselect
with between)
9. Find the names of employees whose address includes the substring 'ma'.(use select with like)
Ans) Address column was dropped earlier in lab 2.
10. Find the names of employees whose name starts with 'sp'.(use select with like)
11.Find the names of employees whose name ends with 'i'.(use select with like)
12.Find the employees' names that exactly contain a five-letter word.(use select with like)
13.Display all employee names in alphabetical order (use select with order by)
14.Display all employee names in descending order (use select with order by, desc)
15.Display the dept no and average salary of employees of each department.(use select with avg and
group by)
16.Select the department_nothat has total salary paid for its employees more than 25000(use select
with sum,group byand where/having)
17.Display the total number of employees(use select with count)
18.Display the average, maximum and minimum salary paid to employees(use select with avg, max
and min)
Download