0% found this document useful (0 votes)
2 views6 pages

My SQL Worksheet2

Uploaded by

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

My SQL Worksheet2

Uploaded by

mitha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

My SQL Worksheet-3

(DDL – Table Related commands)


1. Sahil created a table in Mysql. Later on he found that there should have been
another
column in the table. Which command should he use to add another column to the
table?

2. While creating a table 'Customer' Simrita forgot to set the primary key for the
table. Give
the statement which she should write now to set the column 'CustiD' as the
primary key of the table?

3. Kuhu has already created a table ‘Hospital’ as shown below:

Now she wants to add a new column ‘Address’ to the above given table. Suggest
suitable MySQL command for the same.

4 Write SQL command to remove column named ‘Hobbies’ from a table named
‘Student’.

5. While creating the table Student last week, Ms. Sharma forgot to include the
column Game_Played. Now write a command to insert the Game_Played column
with VARCHAR
data type and 30 size into the Student table?

6. Kunal created the following table with the name ‘Friends’ :Table : Friends
Now, Kunal wants to delete the ‘Hobbies’ column. Write the MySQL statement

7. Rashi wants to add another column ‘Hobbies’ with datatype and size as
VARCHAR(50) in the already existing table ‘Student’. She has written the following
statement. However it has errors. Rewrite the correct statement.
MODIFY TABLE Student Hobbies VARCHAR;

8. Ms. Shalini has just created a table named “Employee” containing


columns Ename, Department, Salary.
After creating the table, she realized that she has forgotten to add a primary key
column in the table. Help her in writing SQL command to add a primary key
column empid. Also
state the importance of Primary key in a table.

9. While creating a table 'Customer' Simrita wrongly added a primary key constraint
to the field “CUSTNAME”. Now she wants to remove the primary key constraint
from the
custname field. Help her in writing the correct command.

10 Mr. Akshat have added a not null constraint to the “name” field in “employees”
. table. But
now he wants to remove that not null constraint. Write the command to delete
the not null constraint from name field.
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?

2. Consider the table RESULT given below.

Write command to insert a new row


6, "Mohan", 500, "English", 73, "Second"

3. Consider the Table SHOPPE given below.

To insert a new row in the table Shoppe


'110', 'Pizza' , 'Papa Jones', 120, "Kolkata", 50.0

4. How is NULL value different from 0 (Zero) value?

5. Consider the following table named "GYM"

Add a new row for a new item in GYM with the details: "G107", "Vibro exerciser”
,21000, “GTCFitness"

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?

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.

3. Write the UPDATE command to change “Sharma” to “Singh” in the “LastName”


column in
the Employee table.

4. What is the use of UPDATE statement in SQL ? How is it different from ALTER
statement?

5. Consider the following table named "GYM"

Write command To change the Brandname to "Fit Trend India" of the item,
whose ICODE as "G101 ".

6. Write the UPDATE statement in to increas by 100.0 in the


MySQL e 0
‘‘Commission’’ column in the ‘Emp’
table.

7. Write two examples of DML commands of SQL.

8. In a database there are two tables ‘CD’ and ‘TYPE’ as shown below :

Write SQL statement to change the name of Singer ‘‘Sonvi Kumar’’ to ‘‘Sonvi
Mehra’’ in all the places wherever it occurs in CD table.

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”
1)

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’.

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.

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.

13. Consider the following table:


Table: PharmaDB

Write commands in SQL to increase the price of “Amlodipine” by 50.

You might also like