DBMS LAB FILE
DBMS LAB FILE
OF
DATABASE MANAGEMENT SYSTEM
PCC-CSE-504
B.TECH CSE 5th SEM
INDEX
PRACTICAL-1
Department of Computer Science and Engineering
AIM:-
To create table using MySQL.
QUERIES:-
(1) Create table according to following schemas
(a) Sailors(sid, sname,rating,age)
(b) Boat(bid, bname, color)
(c) Reserve(sid, bid, day)
(2) Show all table respectively.
(3) Describe the structure of the table.
Syntax:-
CREATE TABLE table_name(
Column1 datatype,
Column2 datatype,
Column3 datatype,
………………
………………..
)
Output:-
QUERIES:-
(1) Find out all the tupples present in sailor table.
(2) Find out all the tupples present in boat table.
(3) Find out all the tupples present in reserves table.
SYNTAX:-
SELECT*FROM table_name;
OUTPUT:-
OUTPUT:-
QUERIES:-
(1) Find out maximum rating in sailor.
(2) Find out the total number of boats.
(3) Find out the number of unique Sid.
(4) Find out the minimum rating from sailors.
(5) Find out the smallest sailor.
SYNTAX:-
(1) SELECT MAX(column1),max(column2),…
FROM table_name;
(2) SELECT SUM(column1),max(column2),…
FROM table_name
WHERE condition;
(3) SELECT COUNT(DISTINCT column1),……
FROM table_name
WHERE condition;
(4) SELECT MIN(column1),…….
FROM table_name
WHERE condition;
OUTPUT:-
QUERIES:-
Create table according to given schema-
a) Dept(deptno, dname, loc);
b) Emp(empno, ename, job,mgr,hiredate,sal,comm,deptno);
SYNTAX:-
1. COUNT
SELECT COUNT(*) FROM table_name
WHERE condition;
SELECT column1, column2,…
FROM table_name
Output:-
QUERIES:-
(i) Find out the name of the sailor who reserves a red Boat but
not green.
(ii) Find out all Sid of sailors who reserve a red or green boat.
(iii) Find out the sailor name who reserves a red Boat.
(iv) Find out the sailor name who reserves a boat on Monday.
(v) Find out the colour of boat reserved by Lubar (sailor name).
(vi) Find out the age of the sailor whose name begins with 'b'
and end with 'b' and has at
least 3 characters.
(vii) Find out the Sid of sailor who have rating of 10 or reserve a
boat 104 (Bid).
SYNTAX:-
SELECT table1name.column1name, table2name.column2name
FROM table1name, table2name
OUTPUT:-
QUERIES:-
(i) Change the job of the employee 'Miller' to Manager.
(ii) Delete the detail of John from employee table.
(iii) Drop the primary key from the employee table.
(iv) Drop the employee table.
(v) Raise the Salary by 10 % and a new column of 15 % of the
Salary for emp from
department 30, who are not eligible for column at present.
(vi) Give the increment of 500 to the manager in the company.
(vii) Disable the primary key in department table.
SYTAX:-
UPDATE table_name
SET column_name1 = Value, Column_name2 = Value
WHERE condition;
ALTER TABLE table_name
OUTPUT:-