DBMS
DBMS
DBMS
PRACTICAL FILE
PRACTICAL NO_1: Create a table named uim_employee having attributes such as:
Employee id, Employee name, Employee’s department number, Employee’s date of joining,
Employee’s salary, Employee’s email and Employee’s contact number.
Consider the following table:
Attribute Datatype Size
employee_id Varchar2 10
employee_name Char 25
employee_department_no Number 03
employee_date_of_joining Date -
employee_salary Number 8,2
employee_email_id Varchar2 30
employee_contact_no Number 12
Note: Insert department number values as 111, 222, 333, 444, …. etc.
Note: Insert employee id values as UU1001, UU1002, UU1003, UU1004, …. etc.
Write SQL queries to:
i. Insert at least 10 tuples in table.
ii. Display employee’s complete details including employee_id, employee_name,
employee_department_no, employee_date_of_joining, employee_salary,
employee_email_id, and employee_contact_no.
iii. Display employee’s complete details including employee_id, employee_name,
employee_department_no, employee_date_of_joining, employee_salary,
employee_email_id, and employee_contact_no who work in department number 444.
iv. Display employee_id, employee_name, employee_date_of_joining who work in
department number 222.
v. Delete the employee’s details having employee_id as UU1003.
vi. Update employee_contact_no to 9592929295 having employee_id as UU1007.
Solution:
i) Query for creating table.
create table uim_employee(
employee_id varchar(10),
employee_name char(25),
employee_department_no int(03),
employee_date_of_joining date,
employee_salary int(20),
employee_email_id varchar(30),
employee_contact_no int(12));
i. Add a new column named employee_address having data type as varchar2, size 30 in
the uim_employee table.
ii. Update the addresses of existing uim_employees in the table.
iii. Drop the column named employee_date_of_joining from the table.
iv. Modify the size of the column named employee_contact_no to 14.
v. Rename the table to uim_employee_details from the table name uim_employee.
vi. Truncate as the records from the uim_employee_details table.
vii. Drop the table named uim_employee_details.
Solution:
i) ALTER TABLE uim_employee ADD employee_address varchar(30);
PRACTICAL NO_3: Implementation of keys and constraints concept. Create a table named
uim_student having attributes such as: student's roll number, student's name, student's date of
birth, student's course, student's house address, student's contact number, student's aadhaar
number. The attribute named: student_roll_no has a PRIMARY KEY constraint, student_name
has NOT NULL constraint, student_aadhaar_no as UNIQUE constraint.
Consider the following table:
Attribute Datatype Size Constraint
student_roll_no Number 3 PRIMARY KEY
student_name Char 25 NOT NULL
student_date_of_birth Date - -
student_course Varchar 15 -
student_address Varchar2 30 -
student_contact_no Number 10 -
student_aadhaar_no Number 12 UNIQUE
i) desc uim_student;
PRACTICAL NO_4: Implementation of Foreign key concept using two tables named:
uim_employee and uim_department. The employee table has employee’s id, employee’s name
and employee’s department number. The department has the department number, department
name and department location.
Consider the following two tables: