You are on page 1of 4

Name

: Vaibhav Bajaj
Enroll No. : 0176IT101030
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\abc>cd\
C:\>cd xampp
C:\xampp>cd mysql
C:\xampp\mysql>cd bin
C:\xampp\mysql\bin>mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.8 MySQL Community Server (GPL)
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases
-> ;
+--------------------+
| Database
|
+--------------------+
| information_schema |
| cdcol
|
| information
|
| it
|
| mysql
|
| performance_schema |
| phpmyadmin
|
| student
|
| test
|
| webauth
|
+--------------------+
10 rows in set (0.05 sec)
mysql> create database project1;
Query OK, 1 row affected (0.02 sec)
mysql> use project1;
Database changed
mysql> create table Proj(Pno int not null,Pname varchar(8) primary key,P_S_D dat
e,P_E_D date,Spons_D varchar(6),Gname varchar(8));
Query OK, 0 rows affected (0.09 sec)
mysql> insert into Proj values("1","Hospital_M","2012-03-14","2012-02-27","IT","
Amit sir");
Query OK, 1 row affected, 1 warning (0.03 sec)
mysql> insert into Proj values("2","Tourist_M","2012-03-18","2012-04-14","IT","A
mit sir");
Query OK, 1 row affected, 1 warning (0.03 sec)
mysql> insert into Proj values("3","Hotel_M","2012-03-19","2012-04-10","EX","Anu
rag sir");

Name
: Vaibhav Bajaj
Enroll No. : 0176IT101030
Query OK, 1 row affected, 1 warning (0.03 sec)
mysql> insert into Proj values("4","Bank_M","2012-03-19","2012-04-10","EX","Anur
ag sir");
Query OK, 1 row affected, 1 warning (0.03 sec)
mysql> insert into Proj values("5","Com.Sys_M","2012-03-13","2012-04-15","EC","Y
ogesh sir");
Query OK, 1 row affected, 2 warnings (0.05 sec)
mysql> insert into Proj values("6","Resv.sys_M","2012-03-3","2012-04-12","EC","Y
ogesh sir");
Query OK, 1 row affected, 2 warnings (0.02 sec)
mysql> select *from Proj;
+-----+----------+------------+------------+---------+----------+
| Pno | Pname | P_S_D | P_E_D | Spons_D | Gname |
+-----+----------+------------+------------+---------+----------+
| 4 | Bank_M | 2012-03-19 | 2012-04-10 | EX | Anurag s |
| 5 | Com.Sys_ | 2012-03-13 | 2012-04-15 | EC | Yogesh s |
| 1 | Hospital | 2012-03-14 | 2012-02-27 | IT | Amit sir |
| 3 | Hotel_M | 2012-03-19 | 2012-04-10 | EX | Anurag s |
| 6 | Resv.sys | 2012-03-03 | 2012-04-12 | EC | Yogesh s |
| 2 | Tourist_ | 2012-03-18 | 2012-04-14 | IT | Amit sir |
+-----+----------+------------+------------+---------+----------+
6 rows in set (0.00 sec)
mysql> select Pname"Project_name",Spons_D"Sponsoring dept",Gname FROM Proj where
Spons_D="EX" ;
+--------------+-----------------+----------+
| Project_name | Sponsoring dept | Gname |
+--------------+-----------------+----------+
| Bank_M
| EX
| Anurag s |
| Hotel_M | EX
| Anurag s |
+--------------+-----------------+----------+
2 rows in set (0.01 sec)
mysql> alter table Proj add No_studs int after P_E_D;
Query OK, 6 rows affected (0.11 sec)
Records: 6 Duplicates: 0 Warnings: 0
mysql> update Proj set No_studs="5" where Pno="1";
Query OK, 1 row affected (0.03 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> update Proj set No_studs="4" where Pno="2";
Query OK, 1 row affected (0.03 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> update Proj set No_studs="5" where Pno="3";
Query OK, 1 row affected (0.02 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> update Proj set No_studs="6" where Pno="4";

Name
: Vaibhav Bajaj
Enroll No. : 0176IT101030
Query OK, 1 row affected (0.03 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> update Proj set No_studs="4" where Pno="5";
Query OK, 1 row affected (0.03 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> update Proj set No_studs="3" where Pno="6";
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select *from Proj;
+-----+----------+------------+------------+----------+---------+----------+
| Pno | Pname | P_S_D | P_E_D | No_studs | Spons_D | Gname |
+-----+----------+------------+------------+----------+---------+----------+
| 4 | Bank_M | 2012-03-19 | 2012-04-10 |
6 | EX | Anurag s |
| 5 | Com.Sys_ | 2012-03-13 | 2012-04-15 |
4 | EC | Yogesh s |
| 1 | Hospital | 2012-03-14 | 2012-02-27 |
5 | IT | Amit sir |
| 3 | Hotel_M | 2012-03-19 | 2012-04-10 |
5 | EX | Anurag s |
| 6 | Resv.sys | 2012-03-03 | 2012-04-12 |
3 | EC | Yogesh s |
| 2 | Tourist_ | 2012-03-18 | 2012-04-14 |
4 | IT | Amit sir |
+-----+----------+------------+------------+----------+---------+----------+
6 rows in set (0.00 sec)
mysql> select Gname,count(Spons_D) from Proj group by Gname having count(Pname)>
1;
+----------+----------------+
| Gname | count(Spons_D) |
+----------+----------------+
| Amit sir |
2|
| Anurag s |
2|
| Yogesh s |
2|
+----------+----------------+
3 rows in set (0.01 sec)
mysql> select Gname,sum(No_studs)from Proj group by Gname;
+----------+---------------+
| Gname | sum(No_studs) |
+----------+---------------+
| Amit sir |
9|
| Anurag s |
11 |
| Yogesh s |
7|
+----------+---------------+
3 rows in set (0.01 sec)
mysql> describe Proj;
+----------+------------+------+-----+---------+-------+
| Field | Type
| Null | Key | Default | Extra |
+----------+------------+------+-----+---------+-------+
| Pno | int(11) | NO | | NULL |
|
| Pname | varchar(8) | NO | PRI | NULL |
|
| P_S_D | date
| YES | | NULL |
|
| P_E_D | date
| YES | | NULL |
|
| No_studs | int(11) | YES | | NULL |
|

Name
: Vaibhav Bajaj
Enroll No. : 0176IT101030
| Spons_D | varchar(6) | YES | | NULL |
| Gname | varchar(8) | YES | | NULL |
+----------+------------+------+-----+---------+-------+
7 rows in set (0.05 sec)

|
|

mysql> select Gname from Proj group by Gname having sum(No_studs) =11;
+----------+
| Gname |
+----------+
| Anurag s |
+----------+
1 row in set (0.00 sec)
mysql> update Proj set P_E_D="2012-04-16" where Gname="Anurag s";
Query OK, 2 rows affected (0.02 sec)
Rows matched: 2 Changed: 2 Warnings: 0
mysql> update Proj set P_E_D="2012-04-1O" where Gname="Amit sir";
Query OK, 2 rows affected, 2 warnings (0.03 sec)
Rows matched: 2 Changed: 2 Warnings: 2
mysql> delete from Proj where curdate()>P_E_D;
Query OK, 2 rows affected (0.03 sec)
mysql> select *from Proj;
+-----+----------+------------+------------+----------+---------+----------+
| Pno | Pname | P_S_D | P_E_D | No_studs | Spons_D | Gname |
+-----+----------+------------+------------+----------+---------+----------+
| 4 | Bank_M | 2012-03-19 | 2012-04-16 |
6 | EX | Anurag s |
| 5 | Com.Sys_ | 2012-03-13 | 2012-04-15 |
4 | EC | Yogesh s |
| 3 | Hotel_M | 2012-03-19 | 2012-04-16 |
5 | EX | Anurag s |
| 6 | Resv.sys | 2012-03-03 | 2012-04-12 |
3 | EC | Yogesh s |
+-----+----------+------------+------------+----------+---------+----------+
4 rows in set (0.00 sec)