Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

A

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 5

create table StudentA

(
Roll_number int,
Name varchar(10),
Gender varchar(10),
Date_of_Birth date,
Contact bigint,
Email varchar(30),
Address varchar(30),
City varchar(10),
Course_name varchar(10),
age int
);

Insert into StudentA


values(1,'Riya','Female','1993/12/20',9824315785,'riya@gmail.com','21-a Apple
plaza','Surat','BCA',30);

Insert into StudentA


values(2,'Priyanka','Female','2002/01/31',7777715785,'priyanka@gmail.com','71-a
Shayona','Surat','BCA',21);

Insert into StudentA


values(3,'Prem','Male','2008/08/20',7777788888,'prem@gmail.com','61-a
Shayona','Vapi','MBA',15);

Insert into StudentA


values(4,'Dixit','Male','1995/01/21',7777989898,'dixit@gmail.com','95-a Apple
squre','Valsad','MBA',28);

Insert into StudentA


values(5,'Dhruvika','Female','2005/07/13',8888888888,'dhruvika@gmail.com','61-a
puna','Vapi','MBA',18);

Insert into StudentA


values(6,'Satish','Male','2002/11/26',9999999999,'satish@gmail.com','B silvar
plaza','Bardoli','BCA',21);

Insert into StudentA


values(7,'Premila','Female','1997/03/03',8887788888,'pamila@gmail.com','61-b Shyam
sundar','Surat','MBA',28);

Insert into StudentA


values(8,'Manju','Female','2008/09/02',7101010107,'Manju@gmail.com','61-a Kargil
chowk','Valsad','MBA',21);

Insert into StudentA


values(9,'Abhi','Male','1997/07/07',7778877888,'abhi@gmail.com','Silver
chock','Bardoli','BCA',26);

Insert into StudentA


values(10,'Yash','Male','2005/08/05',7779999888,'yash@gmail.com','61-a Simran
plaza','Surat','BCA',18);

select * from StudentA;

+-------------+----------+--------+---------------+------------
+--------------------+-------------------+---------+-------------+------+
| Roll_number | Name | Gender | Date_of_Birth | Contact | Email
| Address | City | Course_name | age |
+-------------+----------+--------+---------------+------------
+--------------------+-------------------+---------+-------------+------+
| 1 | Riya | Female | 1993-12-20 | 9824315785 | riya@gmail.com
| 21-a Apple plaza | Surat | BCA | 30 |
| 2 | Priyanka | Female | 2002-01-31 | 7777715785 | priyanka@gmail.com
| 71-a Shayona | Surat | BCA | 21 |
| 3 | Prem | Male | 2008-08-20 | 7777788888 | prem@gmail.com
| 61-a Shayona | Vapi | MBA | 15 |
| 4 | Dixit | Male | 1995-01-21 | 7777989898 | dixit@gmail.com
| 95-a Apple squre | Valsad | MBA | 28 |
| 5 | Dhruvika | Female | 2005-07-13 | 8888888888 | dhruvika@gmail.com
| 61-a puna | Vapi | MBA | 18 |
| 6 | Satish | Male | 2002-11-26 | 9999999999 | satish@gmail.com
| B silvar plaza | Bardoli | BCA | 21 |
| 7 | Premila | Female | 1997-03-03 | 8887788888 | pamila@gmail.com
| 61-b Shyam sundar | Surat | MBA | 28 |
| 8 | Manju | Female | 2008-09-02 | 7101010107 | Manju@gmail.com
| 61-a Kargil chowk | Valsad | MBA | 21 |
| 9 | Abhi | Male | 1997-07-07 | 7778877888 | abhi@gmail.com
| Silver chock | Bardoli | BCA | 26 |
| 10 | Yash | Male | 2005-08-05 | 7779999888 | yash@gmail.com
| 61-a Simran plaza | Surat | BCA | 18 |
+-------------+----------+--------+---------------+------------
+--------------------+-------------------+---------+-------------+------+
10 rows in set (0.00 sec)

select Roll_number,Name,City from StudentA;


+-------------+----------+---------+
| Roll_number | Name | City |
+-------------+----------+---------+
| 1 | Riya | Surat |
| 2 | Priyanka | Surat |
| 3 | Prem | Vapi |
| 4 | Dixit | Valsad |
| 5 | Dhruvika | Vapi |
| 6 | Satish | Bardoli |
| 7 | Premila | Surat |
| 8 | Manju | Valsad |
| 9 | Abhi | Bardoli |
| 10 | Yash | Surat |
+-------------+----------+---------+
10 rows in set (0.00 sec)

> select * from StudentA where Name='Riya';


+-------------+------+--------+---------------+------------+----------------
+------------------+-------+-------------+------+
| Roll_number | Name | Gender | Date_of_Birth | Contact | Email |
Address | City | Course_name | age |
+-------------+------+--------+---------------+------------+----------------
+------------------+-------+-------------+------+
| 1 | Riya | Female | 1993-12-20 | 9824315785 | riya@gmail.com | 21-a
Apple plaza | Surat | BCA | 30 |
+-------------+------+--------+---------------+------------+----------------
+------------------+-------+-------------+------+
1 row in set (0.00 sec)
select * from StudentA where City='Surat';
+-------------+----------+--------+---------------+------------
+--------------------+-------------------+-------+-------------+------+
| Roll_number | Name | Gender | Date_of_Birth | Contact | Email
| Address | City | Course_name | age |
+-------------+----------+--------+---------------+------------
+--------------------+-------------------+-------+-------------+------+
| 1 | Riya | Female | 1993-12-20 | 9824315785 | riya@gmail.com
| 21-a Apple plaza | Surat | BCA | 30 |
| 2 | Priyanka | Female | 2002-01-31 | 7777715785 | priyanka@gmail.com
| 71-a Shayona | Surat | BCA | 21 |
| 7 | Premila | Female | 1997-03-03 | 8887788888 | pamila@gmail.com
| 61-b Shyam sundar | Surat | MBA | 28 |
| 10 | Yash | Male | 2005-08-05 | 7779999888 | yash@gmail.com
| 61-a Simran plaza | Surat | BCA | 18 |
+-------------+----------+--------+---------------+------------
+--------------------+-------------------+-------+-------------+------+
4 rows in set (0.00 sec)

select Name,Contact from StudentA where City='Vapi' OR City='Valsad';


+----------+------------+
| Name | Contact |
+----------+------------+
| Prem | 7777788888 |
| Dixit | 7777989898 |
| Dhruvika | 8888888888 |
| Manju | 7101010107 |
+----------+------------+
4 rows in set (0.00 sec)

Alter table StudentA ADD Age int;


+---------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+-------------+------+-----+---------+-------+
| Roll_number | int | YES | | NULL | |
| Name | varchar(10) | YES | | NULL | |
| Gender | varchar(10) | YES | | NULL | |
| Date_of_Birth | date | YES | | NULL | |
| Contact | bigint | YES | | NULL | |
| Email | varchar(30) | YES | | NULL | |
| Address | varchar(30) | YES | | NULL | |
| City | varchar(10) | YES | | NULL | |
| Course_name | varchar(10) | YES | | NULL | |
| Age | int | YES | | NULL | |
+---------------+-------------+------+-----+---------+-------+

select Roll_number,Name from StudentA where Age>20;


+-------------+----------+
| Roll_number | Name |
+-------------+----------+
| 1 | Riya |
| 2 | Priyanka |
| 4 | Dixit |
| 6 | Satish |
| 7 | Premila |
| 8 | Manju |
| 9 | Abhi |
+-------------+----------+
7 rows in set (0.00 sec)

Alter table StudentA


Rename column Date_of_Birth to DOB;
+-------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+-------------+------+-----+---------+-------+
| Roll_number | int | YES | | NULL | |
| Name | varchar(10) | YES | | NULL | |
| Gender | varchar(10) | YES | | NULL | |
| DOB | date | YES | | NULL | |
| Contact | bigint | YES | | NULL | |
| Email | varchar(30) | YES | | NULL | |
| Address | varchar(30) | YES | | NULL | |
| City | varchar(10) | YES | | NULL | |
| Course_name | varchar(10) | YES | | NULL | |
| Age | int | YES | | NULL | |
+-------------+-------------+------+-----+---------+-------+

select Name,Contact,Email from StudentA where Gender='Female' and


Course_name='MBA';
+----------+------------+--------------------+
| Name | Contact | Email |
+----------+------------+--------------------+
| Dhruvika | 8888888888 | dhruvika@gmail.com |
| Premila | 8887788888 | pamila@gmail.com |
| Manju | 7101010107 | Manju@gmail.com |
+----------+------------+--------------------+

select * from StudentA where Roll_number=7 or Roll_number=5;


+-------------+----------+--------+------------+------------+--------------------
+-------------------+-------+-------------+------+
| Roll_number | Name | Gender | DOB | Contact | Email |
Address | City | Course_name | age |
+-------------+----------+--------+------------+------------+--------------------
+-------------------+-------+-------------+------+
| 5 | Dhruvika | Female | 2005-07-13 | 8888888888 | dhruvika@gmail.com |
61-a puna | Vapi | MBA | 18 |
| 7 | Premila | Female | 1997-03-03 | 8887788888 | pamila@gmail.com |
61-b Shyam sundar | Surat | MBA | 28 |
+-------------+----------+--------+------------+------------+--------------------
+-------------------+-------+-------------+------+
2 rows in set (0.00 sec)

select Name,Contact,Email from StudentA where City='Surat' OR City='Bardoli' and


not Course_name='BCA';
+----------+------------+--------------------+
| Name | Contact | Email |
+----------+------------+--------------------+
| Riya | 9824315785 | riya@gmail.com |
| Priyanka | 7777715785 | priyanka@gmail.com |
| Premila | 8887788888 | pamila@gmail.com |
| Yash | 7779999888 | yash@gmail.com |
+----------+------------+--------------------+
4 rows in set (0.00 sec)

Alter table StudentA


Rename Student_information;
+-------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+-------------+------+-----+---------+-------+
| Roll_number | int | YES | | NULL | |
| Name | varchar(10) | YES | | NULL | |
| Gender | varchar(10) | YES | | NULL | |
| DOB | date | YES | | NULL | |
| Contact | bigint | YES | | NULL | |
| Email | varchar(30) | YES | | NULL | |
| Address | varchar(30) | YES | | NULL | |
| City | varchar(10) | YES | | NULL | |
| Course_name | varchar(10) | YES | | NULL | |
| Age | int | YES | | NULL | |
+-------------+-------------+------+-----+---------+-------+

You might also like