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

standard-mysql

The document is a MySQL worksheet containing multiple-choice questions (MCQs) and SQL command exercises across various sections. It covers topics such as SQL functions, data types, and commands for manipulating tables, as well as practical SQL queries related to sample tables. The worksheet is designed for Level-1 learners to test their understanding of MySQL concepts and commands.

Uploaded by

deivavsbd
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

standard-mysql

The document is a MySQL worksheet containing multiple-choice questions (MCQs) and SQL command exercises across various sections. It covers topics such as SQL functions, data types, and commands for manipulating tables, as well as practical SQL queries related to sample tables. The worksheet is designed for Level-1 learners to test their understanding of MySQL concepts and commands.

Uploaded by

deivavsbd
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/ 6

MySQL WORKSHEET

LEVEL-1
I. MCQ
1. To specify condition with a GROUP BY clause _______clause is used.
(a) USE
(b) WHERE
(c) HAVING
(d) LIKE
2. What values does the count() function ignore?
(a) Repetitive values
(b) Null values
(c ) Characters
(c) Integers
3. Which clause is similar to “Having” clause in Mysql?
(a) SELECT
(b) WHERE
(c) FROM
(d) None of the above
4. Nested grouping can be done by providing __________ in the Group By expression.
(a) SINGLE ROW
(b) MULTIPLE FIELDS
(c) SINGLE COLUMN
(d) MULTIPLE TABLES
5. Predict the output of the query SELECT INSTR(‘[email protected],’.’);
(a) 12
(b) 14
(c) 11
(d) 10
6. Data type of “name” field in a table is char(25). How many bytes will be occupied by values
“Ram” and “Rohan kumar”?
(a) 20
(b) 13
(c) 25
(d) 14
7. Write the output of the following SQL command: SELECT ROUND(458.45,-1);
(a) 450
(b) 460
(c) 458
(d) 500
8. SELECT SUBSTR(“COMPUTER”3,4);
(a) MPUT
(b) PUTE
(c) PU
(d) MP
9. SELECT ROUND(124.44)+MOD(1200.87,3);
(a) 124.87
(b) 1325.31
(c) 1324
(d) 125.98
10. Which command is used to add column in a table?
(a) Addition
(b) Alter
(c) Modify
(d) Select
II. SECTION-B
Consider the following table Timetable.
Write SQL commands for the following statements.(C_teacher = Class Teacher)

Table : Timetable

T_id T_name Subject Workload C_teacher Gender Class


1 Anita Hindi 20 Yes F VIII
2 Aman English 22 Yes M VII
3 Ruby History 24 No F VIII
4 Seema Hindi 20 Yes F IX
a) Display the detail of all teachers in ascending order of workload

b) Display the detail of Class Teacher of Class VIII.

c) Display Name and Subject of all the Class teachers.

d) Display Name and Workload of Hindi Teacher.

e) Display the detail of teacher having maximum workload.

f) Display the detail of teacher having minimum workload.

g) Display the detail of female teacher teaching class VII.

h) Display total of Workload.

i) Display detail of teachers whose name ends with ‘e’

j) Display the class wise workload

k) Display subject wise number of teachers.

l) Display the detail of “Anita” and “Aman” (using IN operator )

m) Display the detail of Class VIII teacher whose workload is more than 20;

n) Display Name, Class and Workload of teacher whose workload is between 20 and 30 (including

both )

o) Increase the workload of all Male teachers by 1.

p) Change the subject of Ruby from “History “to “Math”.


q) Delete the record of “Seema”

r) Delete the column C_teacher.

III. SECTION-C
Consider the following tables Sender and Receiver. Write SQL commands for the statements (a) to (d)
and give the outputs for SQL queries (e) to (h).
Table: Sender

S_id SName S_Add S_City

S101 Mr. Ram 201 Dayanand Vihar New Delhi

S103 Mr. Kumar 125 TownHall Mumbai

S104 Ms. Soni 20 New Hall Mumbai

S106 Mr. Sinha 105 K Aptt Kerela


Table: Receiver

R_id S_id RName R_Add R_City

R231 S101 Mr. Shikhar H-131 AV Vihar New Delhi

R235 S103 Mr. Sethi A12 HK Nagar Mumbai

R236 S101 Mr. Gautam A-75 VM Nagar Kolkata

R241 S106 Ms. Grover M-91 Old Town New Delhi

a) To display the Address of all Senders from New Delhi

b) To display the Receiver id, Sender Name, Sender Address , Receiver City, Receiver Address for
every Receiver.
c) To display Sender details in descending order of Sender City.

d) To display number of Receiver from each city.

e) Select Count(S_City) from Sender;

f) SELECT S.SName, R.RName, S.S_Add From Sender S, Recipient R Where S.S_id = R.S_id AND
R.R_City =’Mumbai’;

g) Select R_id, R_Add from Receiver Where R_City NOT IN (‘Mumbai’, ‘New Delhi’) ;

h) Select R_id, RName from Receiver Where S_id = ’S101’ or S_id=’S103’;

***********

MySQL WORKSHEET
LEVEL-1
IV. MCQ
11. The avg) function in MySql is an example of ___________.
(e) Math Function
(f) Text Function
(g) Data Function
(h) Aggregate Function
12. The month() function in MySql is an example of_____.
(d) Math Function
(e) Text Function
(f) Aggregate Function
(g) Date Function
13. A ________ is a collection of logically related data.
(a) Table
(b) Row
(c) Column
(d) Database
14. Which field you choose as primary key out of following in “Employee” table.
(a) Emp_id
(b) Emp_name
(c) Emp_salary
(d) Emp_desig
15. _________ is the format of date in MySQL.
(a) yyyy-mm-dd
(b) mm-dd-yyyy
(c) dd-yyyy-mm
(d) d-m-year
16. Varchar is a fixed length datatype. (True/False)
17. Which sql function is used to find the highest value in the field.
(a) Min()
(b) Max()
(c) Highest()
(d) Big()
18. Write the command to delete the table employee.
(a) Delete Employee;
(b) Delete table Employee;
(c) Drop table Employee;
(d) Drop Employee table;
19. Which of the following aggregate operation adds up all the values of the attribute?
(a) Add
(b) Avg()
(c) Max()
(d) Sum()
20. What will be the output of the query SELECT LCASE(‘wELCome’);
(a) WELCOME
(b) WelcOME
(c) Welcome
(d) welcome

V. Section- B
1. Write the appropriate datatypes for the following fields.
(i) Dateofbirth
(ii) Salary
(iii) Name
(iv) Address
(v) Phonenumber
2. Name two types of SQL Commands.
3. Identify the DDL and DML commands from the following.
Create, Alter, Insert, Update, Drop, Delete, Select
4. Mysql is an _____________software. (open source/Proprietary)
5. Write any two advantages of database.
6. What is meant by cardinality and degree.
7. Answer the following questions on the basis of the given table.

(a) How many tuples are there in above table?


(b) How many attributes are there in above table?
8. Expand DBMS.
9. Define the following term
Primary key, Foreign key, Candidate key, Alternate key
10. Define the following terms.
POWER(), ROUND()

VI. SECTION-C
1. Write SQL commands to create table STUDENT, which the fields of
ROLLNO,NAME,CLASS,AGE with the specific datatypes.
2. Insert 2 set of values in the above table STUDENT.
3. Give the output for the following queries based on the table GARMENT:

GCODE GNAME SIZE COLOUR PRICE

111 TShirt XL Red 600

112 Jeans L Blue 1200

113 Skirt M Black 1000

(a) SELECT MAX(PRICE) FROM GARMENT;


(b) SELECT COUNT(GNAME) FROM GARMENT;
(c) SELECT GNAME FROM GARMENT WHERE PRICE>1000;
(d) SELECT GCODE FROM GARMENT WHERE GNAME=’TShirt’;
(e) SELECT AVG(PRICE) FROM GARMENT;
4. Consider the following table GAMES. Write SQL commands for the following
statements.
i. To display the name of all GAMES with their GCode.

ii. To display the content of the GAMES table in ascending

order of SDate.

iii. To display sum of PMoney for each Type of GAMES.


******

You might also like