Shaheed Sukhdev College of Business Studies University of Delhi

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 14

SHAHEED SUKHDEV COLLEGE OF BUSINESS STUDIES

UNIVERSITY OF DELHI

INTRODUCTION TO DATABASE MANAGEMENT


SYSTEMS
PRACTICAL-1

PROFESSOR-IN-CHARGE
MR.SATISH GOEL
SHAHEED SUKHDEV COLLEGE
OF BUSINESS STUDIES
(UNIVERSITY OF DELHI)

Submitted by
PRACTICAL 1

SOLUTION:

mysql> create database prac1;

Query OK, 1 row affected (0.09 sec)

mysql> use bms;

Database changed

mysql> create table client(

-> Clientno char(6) primary key,

-> Name varchar(20) not null,

-> City varchar(50) not null,

-> Pin integer,

-> Mobile char(10)

-> );

Query OK, 0 rows affected (0.42 sec)

OUTPUT:
PRACTICAL 2

SOLUTION:

mysql> insert into client

-> values('C0001','Ivan Bayross','Bombay',400054,3456212343);

Query OK, 1 row affected (0.01 sec)

Records: 1 Duplicates: 0 Warnings: 0

mysql> insert into client

-> values('C0002','Vandana Saitwal','Madras',780001,8976532322);

Query OK, 1 row affected (0.01 sec)

Records: 1 Duplicates: 0 Warnings: 0

mysql> insert into client

-> values('C0003','Pramada Jaguste','Bombay',400007,9090898765);

Query OK, 1 row affected (0.01 sec)

Records: 1 Duplicates: 0 Warnings: 0

mysql> insert into client

->values ('C0004','Ravi Shreedharan','Delhi',110020,8727121232);

Query OK, 1 row affected (0.01 sec)

Records: 1 Duplicates: 0 Warnings: 0

mysql> insert into client

-> values('C0005','Rukmani','Kolkata',340003,2312376543);

Query OK, 1 row affected (0.01 sec)

Records: 1 Duplicates: 0 Warnings: 0

mysql> insert into client

-> values('C0006','Pradeep Singhania','Jaipur',130102,1222132333);

Query OK, 1 row affected (0.01 sec)

Records: 1 Duplicates: 0 Warnings: 0

mysql> insert into client

-> values('C0007','George Paul','Kolkata',340010,3323211232);

Query OK, 1 row affected (0.01 sec)

Records: 1 Duplicates: 0 Warnings: 0


mysql> insert into client

-> values('C0008','D Ravichandran','Bombay',400014,2212387896);

Query OK, 1 row affected (0.01 sec)

Records: 1 Duplicates: 0 Warnings: 0

Query OK, 1 row affected (0.01 sec)

Records: 1 Duplicates: 0 Warnings: 0

OUTPUT:
PRACTICAL 3

SOLUTION:

mysql> select Name from client where Name like '%van%';

OUTPUT:
PRACTICAL 4

SOLUTION:

mysql> select * from client where city not like 'Bombay';

OUTPUT:
PRACTICAL 5

SOLUTION:

mysql> SELECT DISTINCT city from client;

OUTPUT:
PRACTICAL 6

SOLUTION:

mysql> create table club(

-> Coachid int primary key,

-> Coachname varchar(20),

-> Age int not null,

-> Sport varchar(10) not null,

-> Dateofapp date,

-> Pay int,

-> Gender char(1) not null

-> );

Query OK, 0 rows affected (0.03 sec)

mysql> insert into club

-> values (1,'Karan',35,'Karate','2019-03-27',10000,'M');

Query OK, 1 row affected (0.23 sec)

Records: 1 Duplicates: 0 Warnings: 0

mysql> insert into club

-> (2,'Ravina',34,'Karate','2020-01-20',12000,'F');

Query OK, 1 row affected (0.23 sec)

Records: 1 Duplicates: 0 Warnings: 0

mysql> insert into club

-> (3,'Kamal',34,'Squash','2020-02-19',20000,'M');

Query OK, 1 row affected (0.23 sec)

Records: 1 Duplicates: 0 Warnings: 0

mysql> insert into club

-> (4,'Tarun',33,'Basketball','2020-01-01',15000,'M');

Query OK, 1 row affected (0.23 sec)


Records: 1 Duplicates: 0 Warnings: 0

mysql> insert into club

-> (5,'Sumeru',36,'Swimming','2020-01-12',7500,'M');

Query OK, 1 row affected (0.23 sec)

Records: 1 Duplicates: 0 Warnings: 0

mysql> insert into club

-> (6,'Anjani',36,'Swimming','2020-02-24',8000,'F');

Query OK, 1 row affected (0.23 sec)

Records: 1 Duplicates: 0 Warnings: 0

mysql> insert into club

-> (7,'Shamima',37,'Squash','2020-02-24',22000,'F');

Query OK, 1 row affected (0.23 sec)

Records: 1 Duplicates: 0 Warnings: 0

mysql> insert into club

-> (8,'Soumya',30,'Karate','2020-02-22',11000,'F');

Query OK, 1 row affected (0.23 sec)

Records: 1 Duplicates: 0 Warnings: 0


OUTPUT:
PRACTICAL 7

SOLUTION:

mysql> select * from club

-> where coachname like '%K%'

-> or pay>=1500;

OUTPUT:
PRACTICAL 8

SOLUTION:

mysql> select Coachname,Pay,Age,Pay*0.15 as Bonus from club;

OUTPUT:
PRACTICAL 9

SOLUTION:

mysql> select * from club where gender='M';

OUTPUT:
PRACTICAL 10

SOLUTION:

mysql> select coachname from club

-> where coachname =‘Karan’ or coachname=’Tarun’ or coachname=’Anjani’ or


coachname=’Soumya’;

OUTPUT:

You might also like