Assesments Day 3
Assesments Day 3
My SQL Worksheet-4
(DML – INSERT INTO commands)
1. Rama is not able to change a value in a column to NULL. What constraint did she specify
when she created the table?
Not null constraint
2. Consider the table RESULT given below.
Add a new row for a new item in GYM with the details: "G107", "Vibro exerciser” ,21000,
“GTCFitness"
Insert into GYM values(“G107”,”Vibro exerciser”,21000,”GTCFitness”);
6. What is meant by NULL value in MySQL?
It indicates that no data is stored in the column
7. Rewrite the following SQL statement after correcting error(s). Underline the corrections
made.
INSERT IN STUDENT(RNO,MARKS) VALUE (5,78.5);
Insert into student(RNO,MARKS) values(5,78.5);
8. Rewrite the following SQL statement after correcting error(s). Underline the corrections
made.
INSERT IN EMP(EMPNO, SALES) VALUE (100, 20078.50);
Insert into emp(empno, sales) values (100,20078.50);
9. Charvi is inserting “Sharma” in the “LastName” column of the “Emp” table but an error is
being displayed. Write the correct SQL statement.
INSERT INTO Emp(‘Sharma’)VALUES(LastName) ;
Insert into emp(LastName) values (‘Sharma’);
10 Anita has created the following table with the name ‘Order’.
.
1
One of the rows inserted is as follows :
(i) What is the data type of columns OrderId and OrderDate in the table Order ?
(ii) Anita is now trying to insert the following row :
2
Informatics Practices
My SQL Worksheet-5
(DML – UPDATE and DELETE commands)
1. What is the purpose of DROP TABLE command in SOL? How is it different from DELETE
command?
Drop command used to delete entire table i.e structure, data and cannot be rolled back.
Delete command used to delete specific rows and it can be rolled back.
2. In a database there are two tables "Product" as shown below :
Write the command To increase the Price of all the Products by 20.
Update ProductName set price = price+20;
3. Write the UPDATE command to change “Sharma” to “Singh” in the “LastName” column in
the Employee table.
Update employee set LastName=”Singh” where LastName = “Sharma”;
4. What is the use of UPDATE statement in SQL ? How is it different from ALTER statement?
Update is used to modify the data, whereas alter is used to modify the structure.
5. Consider the following table named "GYM"
Write command To change the Brandname to "Fit Trend India" of the item, whose ICODE as
"G101 ".
Update GYM set BrandName = “Fit Trend India” where ICODE=”G101”;
6. Write the UPDATE statement in MySQL to increase commission by 100.00 in the
‘‘Commission’’ column in the ‘Emp’ table.
Update Emp set Commission = Commission +100.00;
7. Write two examples of DML commands of SQL.
Insert, update;
8. In a database there are two tables ‘CD’ and ‘TYPE’ as shown below :
3
Write SQL statement to change the name of Singer ‘‘Sonvi Kumar’’ to ‘‘Sonvi Mehra’’ in all
the places wherever it occurs in CD table.
Update CD set SINGER=”Sonvi Mehra” where SINGER=”Sonvi Kumar”;
9. Consider the following table named “GARMENT”.
1) Write command To change the colour of garment with code as 116 to “Orange”.
2) Write command to increase the price of all XL garments by 10%
3) Write command to delete the record with GCode “116”
Update GARMENT set colour=”Orange” where GCODE=116;
Update GARMENT set price = price*1.10 where SIZE=”XL”;
Delete from GARMENT where GCODE=116;
10. In a Database, there are two tables given below :
Write SQL command to change the JOBID to 104 of the Employee with ID as E4 in the table
‘EMPLOYEE’.
Update employee set jobid=104 where employeeid=’E4’;
11. In Marks column of ‘Student’ table, for Rollnumber 2, the Class Teacher entered the marks
as 45. However there was a totaling error and the student has got her marks increased by
5. Which MySQL command should she use to change the marks in ‘Student’ table.
Update Student set marks = marks+5 where Rollnumber =2;
12. Chhavi has created a table named Orders, she has been asked to increase the value of a
column named salesamount by 20. She has written the following query for the same.
Alter table Orders Add salesamount =salesamount+20;
Is it the correct query?Justify.
Update Orders set salesamount = salesamount+20;
13. Consider the following table:
Table: PharmaDB
4
Write commands in SQL to increase the price of “Amlodipine” by 50.
Update PharmaDB set price=price+50 where DrugName=”Amlodipine”;