Lab Program 2
Lab Program 2
City Varchar(20)
Pincode Decimal(6)
State Varchar(20)
Bal_due Decimal(7,2) Not null
describe client_master;
+-----------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+--------------+------+-----+---------+-------+
| client_no | varchar(6) | NO | PRI | NULL | |
| cname | varchar(20) | NO | | NULL | |
| address | varchar(25) | YES | | NULL | |
| city | varchar(20) | YES | | NULL | |
| pin | decimal(6,0) | YES | | NULL | |
| state | varchar(20) | YES | | NULL | |
| bal_due | decimal(7,2) | NO | | NULL | |
+-----------+--------------+------+-----+---------+-------+
b) From the table CLIENT_MASTER create a new table client1 that contains only
Client_no, Name with all records of CLIENT_MASTER.
select*from client1;
+-----------+---------+
| client_no | cname |
+-----------+---------+
| c01001 | ponnu |
| c01002 | mukesh |
| c01003 | siddi |
| c01004 | aswanth |
| c01005 | akash |
| c01006 | sidharth |
| c01007 | manoj |
| c01008 | arjun |
| c01009 | abhijith |
| c01010 | vishnu |
+-----------+---------+
c) From the table CLIENT_MASTER create a new table client2 that has the same
structure as CLIENT_MASTER but with no records
select*from client2;
Empty set (0.00 sec)
d) Insert records into table client3 from the CLIENT_MASTER table where the
Client_nois ‘C01001’.
select*from client3;
+-----------+-------+------------+-----------+--------+-----------+---------+
| client_no | cname | address | city | pin | state | bal_due |
+-----------+-------+------------+-----------+--------+-----------+---------+
| c01001 | ponnu | pandeshwar | mangalore | 575001 | karnataka | 500.00 |
+-----------+-------+------------+-----------+--------+-----------+---------+
f) Update table CLIENT_MASTER change the contents of the field Name to ‘Vijay
Kadam’ and the contents of the field Address to ‘SCT Jay Apmts’ for the record
with Client_no ‘C00002’.
describe client_master;
+-----------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+--------------+------+-----+---------+-------+
| client_no | varchar(6) | NO | PRI | NULL | |
| cname | varchar(20) | NO | | NULL | |
| address | varchar(25) | YES | | NULL | |
| city | varchar(20) | YES | | NULL | |
| pin | decimal(6,0) | YES | | NULL | |
| state | varchar(20) | YES | | NULL | |
| bal_due | decimal(7,2) | NO | | NULL | |
| penalty | decimal(8,2) | YES | | NULL | |
+-----------+--------------+------+-----+---------+-------+