Page 299 - IT-802_class_12
P. 299
Practical Work
Creativity
Subject Enrichment
Computational thinking
1. Write the syntax of ALTER TABLE. Experiential Learning
Ans. Syntax of Alter table is:
ALTER TABLE table_name
ADD column name datatype;
2. Create a table DOCTOR with the fields – DOC_ID, DOC_NAME, DOC_DEPT, DOC_FEE.
+----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| DOC_iD | varchar(10) | yES | | NULL | |
| DOC_NAmE | varchar(40) | yES | | NULL | |
| DOC_DEpT | varchar(20) | yES | | NULL | |
| DOC_FEE | int | yES | | NULL | |
+----------+-------------+------+-----+---------+-------+
Ans. The syntax for creating the given table is:
create table DOCTOR (DOC_iD varchar(10), DOC_NAmE varchar(40), DOC_DEpT varchar
(20), DOC_FEE int);
3. Enter 5 records in the table created in Ques 2.
+--------+---------------+-------------+---------+
| DOC_iD | DOC_NAmE | DOC_DEpT | DOC_FEE |
+--------+---------------+-------------+---------+
| 11001 | Amit Kumar | medicine | 500 |
| 11002 | Suneel Sharma | Neurology | 1000 |
| 11003 | Sonia Gupta | Surgery | 2000 |
| 11004 | Sonam | Gynaecology | 400 |
| 11005 | Kanika | paediatrics | 600 |
+--------+---------------+-------------+---------+
Ans. iNSERT iNTO DOCTOR VALUES(11001, “Amit Kumar”, “medicine”, 500);
iNSERT iNTO DOCTOR VALUES(11002, “Sunil Sharma”, “Neurology”, 1000);
iNSERT iNTO DOCTOR VALUES(11003, “Sonia Gupta”, “Surgery”, 2000);
iNSERT iNTO DOCTOR VALUES(11004, “Sonam”, “Gynaecology”, 400);
iNSERT iNTO DOCTOR VALUES(11005, “Kanika”, “paediatrics”, 600);
4. Write a query to display the name and fee of the Doctor who charges the maximum fee, from the table created in
Ques 2.
Ans. SELECT DOC_NAmE, mAX(DOC_FEE) FROm DOCTOR;
Practical Work 297

