0% found this document useful (0 votes)
2 views

Commands

The document provides SQL commands and queries for creating and manipulating tables, specifically for a 'Students' table and a 'Fabric' table. It includes instructions for creating tables, inserting, updating, and deleting records, as well as displaying specific data based on conditions. Additionally, it suggests appropriate data types for the fields in the tables.

Uploaded by

nehagulati0486
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Commands

The document provides SQL commands and queries for creating and manipulating tables, specifically for a 'Students' table and a 'Fabric' table. It includes instructions for creating tables, inserting, updating, and deleting records, as well as displaying specific data based on conditions. Additionally, it suggests appropriate data types for the fields in the tables.

Uploaded by

nehagulati0486
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

SQL Commands Notes

(a) Write a SQL query to create the table PT1. [ 2 Marks]


(b) Write a query to insert new value to the table. [1 Mark]
(c) Write a query to update the record of ID=102. [1 Mark]
2. Write command and queries to create and manipulate the records of a table named ‘Students’
with the following fields: (1+1+1+1)
Roll_No Name Class Marks
101 Ajay X 765
107 Suraj IX 865
109 Simran X 766
103 Aman IX 821
104 Naresh IX 1
a. Write SQL command to create the above-given table.
b. Set appropriate data types for the fields. (Roll_No, Name, Class, Marks)
c. Write a query to display the details of all the students studying in class X.
d. Write the query to change the Roll_No of the student named “Aman” to 106.
e. How many records and fields are there in given table.
3.

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 );

You might also like