Adobe Scan 07 May 2025
Adobe Scan 07 May 2025
2 Write MySql command will be used to open an already existing database "LIBRARY".
6. Sharmila wants to make the database named COMPANY' active. Write MySQL commands for it.
7 What is MySQL ?
ii
11. Write the command to display the name of the active database.
2 Can a table have multiple primary keys? Can it have multiple foreign keys?
3 In a Student table, out of Roll Number, Name, Address which column can be set
why?
4. Ms. Mirana wants to remove the entire content of a table "BACKUP" alongwith its
the storage space. What MySql statement should she use ?
5. Write MySgl command to create the Table STOCK including its Constraints.
Table STOCK:
Name of Column Type Size Constraint
Company Varchar 20
6 Write one similarity and one difference between CHAR and VARCHAR data types.
7 Saumya had previously created a table named Product' in a database using MySQl
forgot the table structure. Suggest her suitable MySQL command through which st
structure of the already created table.
8 Roliwants to list the names of all the tables in her database named 'Gadgets'. Whic
should use to get the desired result.
11. An attribute A of datatype varchar(20) has the value "Amit". The attribute B of datatype char(20) has
value "Karanita" . How many characters are occupied in attribute A ? How many characters are
occupied in attribute B?
12. Mrs. Sharma is the classteacher of Class XII A' She wants to create a table 'Student'
to store details of her class.
i) Which of the following can be the attributes of Student table?
a) RollNo b) "Amit" c) Name d) 25
i) Name the Primary key of the table 'Student'. State reason for choosing it.
13. Write SQL query to create a table Player' with the following structure:
Field Type Constraint
playerid Integer Primary key
name Varchar(50)
height Integer
weight Integer
datebirth Date
teamname Varchar(50)
14. Anita has created the following table with the name Order'.
Table : Order
15. Write SQL query to create a table 'Event' with the following structure:
Field Type Constraint
Eventld Varchar(5) PRIMARY KEY
EventName Varchar(30) NOT NULL
Location Varchar(50)
ClientlD Integer
EventDate Date
16. Observe the given table carefully and answer the following questions:
PanNo Name Phoneno Address
CIZPW123A Rajesh Kumar 9599123456 WZIl - Rajouri
Garden, Delhi
ABWQ2341B Hemant Kumar 9812345678 Modern
Apartments,
Pitampura, Delhi
DERA9786T Naveen Sharma 7868654235 CA 22, Sector 21
Robini.Delhi
PARD3457L Sourabh Vena 893321 7645 JD 61,
Sector20,Gurgaon
GDTFS762P Nishant Kumar NULL Modern
Apart1ments,
Pitampura, Delli
MERT2376G Hemant Kumar 9811110891 F40, Sector 19,
Rohini, Delli
i. Name the column that might have a Primary Key constraint. Justify your answer.
ii. Name the column that might have a Unique constraint. Justify your answer.
17. "ABC" Event Management Company requires data of events that are to be organized. Write SQL query
to create a table 'Event' with the following structure
Field Type Constraint
DateEvent Date
NumPerformers Integer
18. suggest her suitable command for the following purpose:
iv. To display the list of the database already existing in MySQL.
V To use the database named City.
vi. To remove the pre-existing database named Clients.
vii. To remove allthe records of the table named "Club" at one go along with its structure
permanently.
19. While creating a table named "Employee", Mr. Rishi got confused as which data type he should chose
for the column "EName" out of char and varchar. Help him in choosing the right data type to store
employee name. Give valid justification for the same.
My SQL Worksheet-3
(DDL - Ater Table 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?
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?
|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.
Informatics Practices
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?
7. Rewrite the following SQL statement after correcting error(s). Underline the corrections made.
INSERT IN STUDENT(RNO,MARKS) VALUE (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);
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):
10. Anita has created the following table with the name 'Order'.
7
Table : Order
OrderAmount
Storeld
11. In today's digitized world with a need to store data electronically, it is very important to store the data in
the databases. SQL is used to interact with the Database Management System.
Classify the following commands according to their type :(DDL/DML)
i. INSERT INTO ii. ALTER TABLE
4. What is the use of UPDATE statement in SQL ? How is it different from ALTER statement?
6. Write the UPDATE statement in MySQL to increase commission by 100.00 in the "Commission" column
in the 'Emp' table.
8. In a database there are two tables 'CD' and TYPE' as shown below :
Table: CD Table:TYPE
CODE TITLE DURATION SINGER CATEGORY
CATEGORY DESCRIPTION
101 Sufi Songs 50 min Zakir Faiz 12
1 Jazz
102 Eureka 45 min Shyama Mukherjee 12
103 Nagmey 23 min Sonvi Kumar 77 12 Classical
104| Dosti 35 min Bobby 1 40 Country Side
78 Pop
Write SQL statement to change the name of Singer "Sonvi Kumar" to "Sonvi Mehra" in all the places
wherever it occurs in CD table.
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"
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.
10
10. In a Database, there are two tables given below
Table : EMPLOYEE
EMPLOYEEID NAME SALES JOBID
SAMIT SINHA 1100000 102
E2 VIJAY SINGH TOMAR 1300000 101
E3 AJAY RAJPAL 1400000 103
E4 MOHIT RAMNANI 1250000 102
E5 SHAILJA SINGH 1450000 103
Table: JOB
JOBID JOBTITLE SALARY
101 President 200000
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 ofa column named
salesamount by 20. She has written the following query for the same.
10
3. Consider the table TEACHER given below. Write commands in SQL for (1) to (3) and outputf
ID Name Department Hiredate Category Gender Salary
1 Tanya Nanda SocialStudies 1994-03-17 TGT 25000
2 Saurabh Sharma Art 1990-02-12 PRT M 20000
Nandita Arora English 1980-05-16 PGT 30000
James Jacob English 1989-10-16 TGT M 25000
Jaspreet Kaur Hindi 1990-08-01 PRT 22000
Disha Sehgal Math 1980-03-17 PRT F 21000
7 Siddharth Kapoor Science 1994-09-02 TGT M 27000
8 Sonali Mukherjee Math 1980-11-17 TGT F 24500
4. The Item_No and Cost columna of a table "ITEMS" are given below:
IITEM NO COST Based on this information, find the output of the following queries:
101 5000
a) SELECT COST +100 FROM ITEMS WHERE ITEM_NO > 103;
102 NULL
103 4000
104 6000
105 NULL
5. Consider the table Projects given below. Write commands in SOL for i) to ii) and output for iv)
PROJECTS
ID ProjName ProjSize StartDate EndDate Cost
1 Payroll-MMS Medium 2006-03-17 2006-09-16 60000
2 Payrol-ITC Large 2008-02-12 2008-01-11 500000
3 IDMgmt-LITL Large 2008-06-13 2009-05-21 300000
4 Recruit-LITL Medium 2008-03-18 2008-06-01 50000
6 IDMgmt-MTC Small 2007-01-15 2007-01-29 20000
5 Recruit-ITC Medium 2007-03-01 2007-06-28 50000
i. To display all information about projects of"Medium" ProjSize
i. To list the ProjSize of projects whose ProjName ends with LITL.
ii. To list ID, Name, Size, and Cost of all the projects in descending order of StartDate.
iv. SELECT DISTINCT ProjSize FROM projects
8. Consider the table RESULT given below. Write commands in MySql for () to (ii)
Table : Result
No Name Stipend Subject Average Division
() To list the names of those students, who
- Sharon 400 English 38 THIRD have obtained Division as FIRST in the
2 Amal 680 Mathematics 72 FIRST ascending order of NAME.
Vedant 500 Accounts 67 FIRST () To display a report listing NAME, SUB
4 Shakeer 200 Informatics 55 SECOND and Annual stipend received assuming tha
Anandha 400 History 85 FIRST stipend column has monthly stipend.
6 Upasna 550 Geography 45 THIRD
10 Consider the Table SHOPPE given below. Write command in MySql for () to (ii)
Table SHOPPE
Code Item Company Qty City Price
() To display names of the items whose name s
102 Biscuit Hide & Seek 100 Delhi 10.00 with C' in ascending order of Price.
103 Jam Kissan 110 Kolkata25.00 (i) To display Code, Item name and City of
101 Coffee Nestle 200 Kolkata 55.00 products whose quantity is less than 100.
106 Sauce Maggi 56 Mumbai55.00
107 Cake Britannia 72 Delhi 10.00
104 Maggi Nestle 150 Mumbai10.00
105 Chocolate Cadbury 170 Delhi 25.00
11. What is used in the SELECT clause to return all the columns in the table?
12. In MySQL, Sumit and Fauzia are getting the following outputs of ItemCodes for SELECT statements
used by them on a table named ITEM.(Both have used the SELECT statements on the same table ITEM).
Sumit's Output Fauzia's Output
101 101
102 102
101 105
105 107
101
107
Which extra keyword has Fauzia used with SELECT statement to get the above output?
13. Consider the table 'PERSONS' given below. Write commands in SQL for () to (iv) and write output for ().
Table : PERSONS
Pld Surname Firstname Gender City PinCode BasieSalary () Display the SurNames, FirstNames and
Sharma Geeta Udhamwara 182141 50000 Cities of people residing in Udhamwara
Singh Surinder Kupwara 183222 75000
city.
Narar (i) Display the Person Ids (PID), cities and
Jacob Peter M Bhawani 185155 45000 Pincodes of persons in descending order
Alvis Thomas M Ahmed 380025 50000
of Pincodes.
Nagar
(ii) Display the First Names and cities of
Mohan Garima M Nagar 390026 33000
all the females getting Basic salaries
Coolangatta
above 40000.
Azmi Simi New Delhi 110021 40000
Kaur ManproetF Udhamwara 182141 42000
(iv) Display First Names and Basic Salaries
of all the persons whose firstnames star
with "G"
(v) SELECT Surname FROM Persons Where BasicSalary>=50000;
14. Mr. Tondon is using table EMP with the following columns.
ECODE,DEPT,ENAME,SALARY
He wants to display all information of employees (from EMP table) in ascending order of ENAME and
within it in ascending order of DEPT. He wrote the following command, which did not show the desired
output.
SELECT * FROM EMP ORDER BY NAME DESC,DEPT;
Rewrite the above query to get the desired output.
15. Consider the following table named "GYM" with details about fitness items being sold in the store. Write
command of SQL for (i) to (i).
Table GYM:
1CODE INAME PRICE BRANDNAME
) To display the names of all the items whose name starts
GIOt Power Fit Exerciser 20000 Power Gymea
with "A".
GI02 Aquafit Hand Grip 1800 Reliable
14000 Ecobike
() To display ICODES and INAMES of all items, whose
GIO3 Cycle Bike
Brandname is Reliable or Coscore.
GIO4 Protoner Extreme Gym 30000 |Coscore
GI05 Message Belt 5000 MessagEpert
GI06 lCross Trainer 13000 GTCFitness
|4
16. Consider the following table named 'SBOP" with details of account holders. Write commands of MySql
forTable(i): SBOP
to (i) and output for (ii).
Accountao Name Balance DateOtopen Tranaton
() To display Accountno, Name and DateOfopen of account
15000.o0 2011-02-24 holders having transactions more than 8.
SB-2 Nr.Aait 23567.a9
() To display al information of account holders whose
transaction value is not mentioned.
45000.00 2012-02-04
S8-3 E.Sakahi
(ii) SELECT NAME,BALANCE FROM SBOP WHERE NAME LIKE
S3-4 .Gopal 23812.35 2013-09-22 "%i":
17. When using the LIKE clause, which wildcard symbol represents any sequence of none, one or more
characters ?
18. Consider the table FLIGHT given below. Write commands in SQL for () to (iv) and output for ().
Table: FLIGHT
FLCODE START DESTINATION NO _STOPS NO_ FLIGHTS
IC101 DELHI AGARTALA 1 5
IC102 MUMBAI SIKKIM 1
IC103 DELIHI JAIPUR 7
IC105 KANPUR CIIENNAI 2
IC107 MUMBAI KANIPUR 0
IC431 INDORE CHENNAI 3 2
IC121 DELII AIIMEDABAD 2 6
19. What will be the output of the following queries on the basis of Employee table:
+
21. Consider the following table named "GARMENT".Write command of SQL for ()
to (iv) and output for (v) to (vi).
Table : GARMENT () To display names of those garments that
GCODE GNAME SIZE COLOUR PRICE are available in 'XL' size.
111 TShirt XL Red 1400.00 (i) To display codes and names of those garments
112 Jeans Bl ue 1600.00
that have their names starting with 'Ladies'.
113 Skirt M
(ii) To display garment names, codes and prices of
Black 1100.00
those garments that have
114 Ladies Jacket XL Blue 4000.00 price in the range 1000.00 to 1500.00 (both
115 Trousers L Brown 1500.00 1000.00 and 1500.00 included).
116 Ladies Top Pink 1200.00
(iv) SELECT GNAME FROM GARMENT WHERE
SIZE IN (M, L) AND PRICE> 1500;
107 NULL
Jatinder Chennal
Mumbai
Deepa Mumbal
Chennai
Harsh Chennal
26. Write commands in SQL for (0) to (ii) and output for (iv).
Table : Store
Storeld Name City
Location NoOfEmployees Datepened| SalesAmount
S101 Planetfashion KarolBagh Delhi 7 2015-10-16 300000
S102 Trends Nehru Mumbai 11 2015-08-09 400000
Nagar
S103 Vogue Vikas Delhi 10 2015-06-27 200000
Vihar
S104 Superfashion Defence Delhi 8 2015-02-18 450000
Colony
S105 Rage Bandra Mumbai 5 2015-09-22 600000
() To display name, Iocation, city, SalesAmount of stores in descending order of SalesAmount.
(i) To display names of stores along with SalesAmount of those stores that have fashion' anywhere in
their store names.
(ii) To display Stores names, Location and Date Opened of stores that were opened before 1st March,
2015.
(iv) SELECT distinct city FROM store;
27. Which clause would you use with Select to achieve the following:
i.To select the values that match with any value in a list of specified values.
ii.Used to display unrepeated values of a column from a table.
ii. To display all those medicines whose price is in the range 100 to 150.
ii. To display the Drug ID, DrugName and Pharmacy Name of all the records in descending order of their
price.
iv. SELECT RxlD, DrugName, Price from PharmaDB where PharmacyName IN ("Rx Parmacy", "Raj
Medicos"):
29. Write SQL statement that gives the same output as the following SQL statement but uses 'IN' keyword.
SELECT NAME FROM STUDENT WHERE STATE = VA':
30. Which one of the following SQL queries will display all Employee records containing the word "Amit",
regardless of case (whether it was stored as AMIT, Amit, or amit etc.) ?
() SELECT* from Employees WHERE EmpName like UPPER'%AMIT%;
(ii) SELECT *from Employees WHERE EmpName like %AMIT% or "%AMIT% OR '%amit%;
(ii) SELECT *from Employees WHERE UPPER (EmpName) like "%AMIT%;