Professional Documents
Culture Documents
Alok Dbms
Alok Dbms
Alok Dbms
Output
Query:
Select * from uscs_emp;
Output
2|Page
3
Query:
SELECT emp_id, emp_name, emp_date_join FROM uscs_emp WHERE emp_dept_no = '333';
Output
Query:
DELETE FROM uscs_emp WHERE emp_id = 'UU1003'
Output
Query:
UPDATE uscs_emp SET contact ='95929'
WHERE emp_id = 'UU1007';
Output
FINAL TABLE:
Output
PRACTICAL NO-02:
Implement DDL and DML on the uim_employee table. Consider the following employee
table:
Attribute Data type Size
emp_id Varchar2 10
emp_name Char 25
emp_dept_no Number 03
emp_date _join Date -
emp_salary Number 8,2
email_id Varchar2 30
contact_no Number 12
Query:
create table uim_emp(
emp_id varchar(20),
emp_name varchar(20),
emp_dep_no int,
emp_date_join date,
emp_salary int,
email_id varchar(20),
contact int);
Output
Add a new column named emp_address having data type as varchar2, size 30 in the
uim_employee table.
Query:
ALTER TABLE uim_emp
ADD emp_address VARCHAR(30);
Output
Query:
UPDATE uim_emp
SET emp_address = 'DEHRADUN';
Output
Output
Query:
ALTER TABLE uim_emp
MODIFY contact int(14);
Output
Query:
ALTER TABLE uim_emp
RENAME TO emp_details;
Output
Query:
TRUNCATE TABLE emp_details;
Output
Query:
DROP TABLE emp_details;
Output
PRACTICAL NO_3:
Implement 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:
Query:
create table uim_student(
rollno int primary key,
s_name varchar(20) not null,
date_of_birth date,
s_course varchar(20),
s_address varchar(30),
s_contact int(20),
s_aadhaar int(30));
Output
Query:
DESCRIBE uim_student;
Output
Query:
INSERT INTO uim_student
values("111","Yashank Gupta","2004-05-24","BCA","HARIDWAR","989720", "841631486");
Examine the error message by inserting same student_roll_no values for two rows. Write
the error message and reason.
Query:
INSERT INTO uim_student VALUES ("111","Alok Gupta","2009-04-12","B-
Tech","Landon","898720","78631486");
Output
Examine the error message by NOT inserting student_name value in a row in the table.
Write the error message and reason.
Query:
INSERT INTO uim_student (roll no, date_of_birth, s_course, s_address, s_contact, s_aadhaar)
VALUES ("444","2004-03-24","BCA","DEHRADUN","951984", "65483148");
Output
Examine the error message by inserting same student s_aadhaar values for two rows.
Write the error message and reason
Name -Alok singh rana ROLL NO-2209000045 BCA 3rd ,” E”
12
Query:
INSERT INTO uim_student
VALUES ("444","ADARSH","2002-08-05","BCA","PREMNAGAR","498563",
“5685650'");
Output
FINAL TABLE
Output
PRACTICAL NO_4:
Implement of foreign key concept using two tables named: uscs_emp and uscs_dep. The
employee has employee’s id, employee’s name, employee’s department number. The
department table has department name and department location.
Consider the following two table:
Query:
CREATE TABLE uscs_dep(
dep_id CHAR(8),
dep_name VARCHAR(20),
dep_loc INT(3),
PRIMARY KEY (dep_id));
Output
Query:
DESCRIBE uscs_emp2;
Output
Query:
DESCRIBE uscs_dep;
Output
Query:
INSERT INTO uscs_dep
VALUES ("aaaa","CODEX","111");
Query:
SELECT * FROM uscs_dep;
Output
Query:
INSERT INTO uscs_emp2(emp_id, emp_name, emp_dep) VALUES
("xxxx","SWATI SINGH","111"),
("yyyy","MANISHA KHANDUJA","222"),
("zzzz","PREVEEN","333);
Output
Query:
SELECT * FROM uscs_emp2;
Output
Examine the error message by inserting a value in emp_dep which is NOT there in
uscs_dep table’s departments. Write the error message and reason.
Query:
INSERT INTO emp_dep (emp_name, dep_id)
VALUES ("John Doe", "NonexistentDept");
Output
Delete any department number from uscs_dep table and examine its effects in uscs_emp2
table.
Query:
DELETE FROM uscs_dep WHERE dep_loc = '111';
Output
Query:
DELETE FROM uscs_emp2 WHERE emp_dep = '111';
Output
PRACTICAL NO-05:
Create a table named employee_contact_details from employee table by taking the attribute
named: employee_id. Perform Add, Update and Display operations.
Query:
create table employee
(
emp_id int,
emp_name varchar (32),
emp_age int
);
desc employee;
insert into employee values(101,'Aman',20);
insert into employee values(103,'Ronit',19);
Display data of employee table
Query: -
Select * from employee;
Output
Display emp_contact_details
Query: -
Select * from emp_contact_details;
Output
PRACTICAL 6: -
Create a table named uim_book having the attributes related to book id, book name and
book theme. The book theme attribute can have only two values: IT or MGT where IT is
Information Technology and MGT is Management. Apply CHECK constraint on the
attribute named book theme.
Query: -
CREATE TABLE uim_book (
book_id INT PRIMARY KEY,
book_name VARCHAR(255),
book_theme VARCHAR(3) CHECK (book_theme IN ('IT', 'MGT'))
);
Query: -
insert into uim_book values (102,"Principles of Management”, MGT');
Query: -
insert into uim_book values (103,"Health and Care’s');
PRACTICAL 8: -
The data in the table can be grouped based on certain attributes. Consider the book table
having attributes Aboukir, book name, book theme and book_price. Perform operations on
Group. Note: the book theme can either be 'it' or 'mgt'
Query: -
drop database Practical_08;
create database practical_08;
use practical_08;
create table uscs_book (
book_id varchar (10) primary key,
book_name varchar (25) not null,
book_theme varchar (4) check (book_theme in ("cs", "it"))
);
Output
Query: -
select * from uscs_book;
Output
Query: -
alter table uscs_book add book_prise decimal (7);
Query: -
select * from uscs_book;
Output
Query: -
update uscs_book
Query: -
insert into uscs_book values ("UU100", "PYTHON", "cs", 285)
Output
Query: -
select * from uscs_book;
Output
9
Query: -
select sum(book_prise) as total_book_prise from uscs_book;
Output
Query: -
select max(book_prise) as max_book_prise from uscs_book;
Output
PRACTICAL 9: -
There are numerous aggregate functions that can be performed on table(s). Consider the
attributes in the employee table as: employees id, employees name, employees
department number, employees’ designation, employees date of joining, employee’s
salary, employees email id, employees contact no and employees Aadhaar number.
Create
Query: -
database practical_09;
use practical_09;
select * from uim_employee;
drop database practical_09;
create table uu_employee (
employee_id varchar (30) primary key,
employee_name char (25) not null,
employee_department_no int (3) not null,
employee designation varchar (15) not null,
employee_date_of_joining date not null,
employee_salary float (8) not null,
employee_email_id varchar (30) not null,
employee_contact_no varchar (12) not null,
employee_aadhar_no varchar (12) unique
);
Output
Inserting a value
Query: -
Query: -
select * from uu_employee;
Output
Query: -
select sum(employee_salary) as total _salaries from uu_employee;
Output
Query: -
select sum(employee_salary) as total_salaries from uu_employee where employee_
department _no= 222;
Output
PRACTICAL 10: -
Create uim_employee table.
i) Count the number of employees in the uim_employee table.
ii) Display the maximum salary of employees having employee designation as assistant
prof.
iii) Display the minimum salary of employees having employee designation as Professor
iv) Calculate the average of salaries of all the employees
Query:
create database Practical_10;
use Practical_10;
drop database Practical_10;
create table uim_employee (
employee_id varchar (30) primary key,
employee_name char (25) not null,
employee_department_no int (3) not null,
employee designation varchar (30) not null,
employee salary float (8) not null
);
Output
Query:
insert into uim_employee values
Query:
select * from uim_employee;
Output
Query:
select count (*) as total employees from uim_employee;
Output
Query:
select max (employee salary) as max_salary from uim_employee where employee
designation = "Assistant Professor";
Output
Query:
select min (employee salary) as max_salary from uim_employee where employee
designation = "Professor";
Output
PRACTICAL 11: -
Implement the single-row character function on the customer table. The customer table as
attributes related to customers id, customers first name, customers last name, customers
contact number, customers house number, customers street of address, customers city of
address, customers state of address and customers email id
Query:
create table customer (
customer varchar (10) primary key,
customer_first_name char (25) not null,
customer_last_name char (25),
customer_contact_no varchar (03) not null,
customer_house_no varchar (03),
customer_house_street varchar (15),
customer_house_city varchar (15),
customer_house_state varchar (15),
customer_email_id varchar (20)
);
Output
Query:
insert into customer values("UU1001", "MD", "ALI", "620", "52", "Mainblock", "Ara",
"BIHAR", "md4314674@gmail.com"),
("UU1002", "Lucky", "Kumar", "720", "216", "Railway Station", "ARA", "BIHAR",
"lucy620@gmail.com"),
("UU1003", "Shaddab", "ALAM", "926", "49", "Village", "Gaya", "BIHAR",
"pawan5427@gmail.com");
Query:
Query:
select concat (customer_first_name, ' ', customer_last_name) as full_name
from customer
limit 0, 1000;
Output
Query:
select UPPER (customer_first_name) as uppercase_first_name
from customer;
Output
Query:
select
concat (ucase (left (customer_house_city, 1)), lcase (substring (customer_house_city, 2)))
as formatted_city
from customer;
Output
PRACTICAL 12: -
Implement the date functions on uu_employee table. Consider the attributes in the
employee table as: employees id, employees name, employees department number,
employees’ designation, employees date of joining, employees salary, employees email
id, employees contact no, employees Aadhaar number and employees date of resigning.
Query:
create database practical_12;
use practical_12;
drop database practical_12;
-- (this is comment) SAIF
create table uu_employee(
employee_id varchar(10) primary key,
employee_name char(25) not null,
employee_department_no int(3) not null,
employee_designation varchar(15) not null,
employee_date_of_joining date not null,
employee_salary float(8) not null,
employee_email_id varchar(30) not null,
employee_contact_no varchar(12) not null,
employee_aadhar_no varchar(12) unique
);
Output
Query:
describe uu_employee;
Output
Query:
Query:
Query:
Output
Query:
Output
Query:
Output