Commands
Commands
1. Write the SQL Commands to answer the queries based on Fabric Table.
FabricID FabricName Type Disc
F002 Suits Cotton 20
F003 Kurta Woolen 10
F004 Jeans Denim 15
F005 Shorts Cotton 7
F007 Sarees Silk 11
a. Suggest a suitable data type for the FabricName, Disc fields.
Ans. FabricName-Varchar
Disc-Integer
b. Write SQL commands to create the given table?
Ans. Create table fabric (FabricID char(4),FabricName varchar(20), Type varchar(15), Disc integer);
c. Add a new record with following details:
(“F001”,”jackets”,”Leather”,”6”)
Ans. Insert into Fabric values (‘F001’,’Jackets’,’Leather’,’6’);
d. Write a query to display all the records of table.
Ans. Select * from Fabric;
e. To display only those Fabric Name whose disc is more than 10
Ans. Select Fabric Name from Fabric where disc>10;
f. To Display those records whose type is ‘woolen’.
Ans. Select * from Fabric where type=’woolen’;
g. To modify the disc of fabric jeans from 15 to 18.
Ans. Update Fabric set disc=’18’ where fabricName=’Jeans’;
h. To view records in ascending order of FabricName from the table
Ans. select * from fabric order by “FabricName” ASC;
i.To delete the record of fabric ‘F002’ from the table.
Ans. Delete * from fabric where fabricID=’F002’;
2.
Ans. Create table items( Itemno integer Primary key, Iname varchar(15), Price Numeric(10,2),
Quantity Integer );