MySQL Hospital Database Assignment
This assignment demonstrates the creation and management of a Hospital database in
MySQL. The operations include creating databases and tables, inserting, updating, deleting,
altering, and displaying records using SQL queries. The format imitates a terminal-based,
step-by-step walkthrough.
1. Creating the Hospital Database
mysql> CREATE DATABASE Hospital;
Query OK, 1 row affected (0.01 sec)
2. Using the Database
mysql> USE Hospital;
Database changed
3. Creating the Patient Table
mysql> CREATE TABLE Patient(
-> P_ID INT(20),
-> P_name VARCHAR(100),
-> age INT(10),
-> gender VARCHAR(20),
-> contact INT(50),
-> Address VARCHAR(100)
);
Query OK, 0 rows affected, 3 warnings (0.03 sec)
4. Describing the Patient Table
mysql> DESC Patient;
Field Type Null Key Default Extra
P_ID int YES NULL
P_name varchar(1 YES NULL
00)
age int YES NULL
gender varchar(2 YES NULL
0)
contact int YES NULL
Address varchar(1 YES NULL
00)
5. Inserting Records into Patient
mysql> INSERT INTO Patient(P_ID, P_name, age, gender, contact,
Address) VALUES
-> (1111, 'Yash Suryawanshi', 18, 'Male', 899988, 'Nashik'),
-> (2222, 'Mahesh Tamnar', 19, 'Male', 869478, 'Nagar'),
-> (3333, 'Prashant Suthar', 19, 'Male', 987987,
'Ahemdnagar'),
-> (4444, 'Harshal Suryawanshi', 18, 'Male', 967483,
'Nashik'),
-> (5555, 'Drushti Shah', 20, 'Female', 78956, 'Pune'),
-> (6666, 'Pranjal Jain', 19, 'Female', 82421, 'Mumbai'),
-> (7777, 'Sakshi Patil', 18, 'Female', 837290, 'Baner'),
-> (8888, 'Saloni Ankaikar', 20, 'Female', 64382, 'Pune');
Query OK, 8 rows affected (0.01 sec)
6. Viewing Records from Patient
mysql> SELECT * FROM Patient;
P_ID P_name age gender contact Address
1111 Yash 18 Male 899988 Nashik
Suryawans
hi
2222 Mahesh 19 Male 869478 Nagar
Tamnar
3333 Prashant 19 Male 987987 Ahemdnaga
Suthar r
4444 Harshal 18 Male 967483 Nashik
Suryawans
hi
5555 Drushti 20 Female 78956 Pune
Shah
6666 Pranjal 19 Female 82421 Mumbai
Jain
7777 Sakshi 18 Female 837290 Baner
Patil
8888 Saloni 20 Female 64382 Pune
Ankaikar