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

12_ip_mysql

The document is a MySQL worksheet divided into multiple levels, containing multiple-choice questions (MCQs), SQL commands, and theoretical questions related to MySQL and database concepts. It covers topics such as data types, SQL functions, table creation, and constraints, along with practical exercises for SQL queries. The worksheet is designed for learners to test their knowledge and skills in MySQL at different levels.

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)
4 views

12_ip_mysql

The document is a MySQL worksheet divided into multiple levels, containing multiple-choice questions (MCQs), SQL commands, and theoretical questions related to MySQL and database concepts. It covers topics such as data types, SQL functions, table creation, and constraints, along with practical exercises for SQL queries. The worksheet is designed for learners to test their knowledge and skills in MySQL at different levels.

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

MySQL WORKSHEET

LEVEL-1
I. MCQ
1. The avg) function in MySql is an example of ___________.
(a) Math Function
(b) Text Function
(c) Data Function
(d) Aggregate Function
2. The month() function in MySql is an example of_____.
(a) Math Function
(b) Text Function
(c) Aggregate Function
(d) Date Function
3. A ________ is a collection of logically related data.
(a) Table
(b) Row
(c) Column
(d) Database
4. 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
5. _________ is the format of date in MySQL.
(a) yyyy-mm-dd
(b) mm-dd-yyyy
(c) dd-yyyy-mm
(d) d-m-year
6. Varchar is a fixed length datatype. (True/False)
7. Which sql function is used to find the highest value in the field.
(a) Min()
(b) Max()
(c) Highest()
(d) Big()
8. Write the command to delete the table employee.
(a) Delete Employee;
(b) Delete table Employee;
(c) Drop table Employee;
(d) Drop Employee table;
9. Which of the following aggregate operation adds up all the values of the attribute?
(a) Add
(b) Avg()
(c) Max()
(d) Sum()
10. What will be the output of the query SELECT LCASE(‘wELCome’);
(a) WELCOME
(b) WelcOME
(c) Welcome
(d) welcome

II. Section- B
1. Write the appropriate datatypes for the following fields.
(i) Dateofbirth
(ii) Salary
(iii) Name
(iv) Address

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

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

2
order of SDate.

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


******
MySQL WORKSHEET
LEVEL-2
IV. MCQ
11. Duplication of record is called ___________.
(e) Duplicate
(f) Redundancy
(g) Integrity
(h) Aggregate
12. The month() function in MySql ia an example of_____.
(e) Math Function
(f) Text Function
(c ) Data Function
(g) Aggregate Function
13. Find the output for the following query
SELECT RIGHT(‘SOFTWARE’,2);
(a) RE
(b) WA
(c) OFTWARE
(d) O
14. SELECT ROUND(79.987,2)
(a) 79
(b) 80
(c) 79.99
(d) 79.9
15. SELECT MOD(20,3);
(a) 1
(b) 2
(c) 3
(d) 4
16. SELECT INSTR(‘INFORMATION FORM’,’FOR’);
(a) 3
(b) 12
(c) 13
(d) 2
17. The command ______ can be used to make changes in the rows of a table in SQL.
(a) Alter
(b) Update
(c) Delete
(d) Change
18. Which command can be used to arrange data in some order in a table in SQL.
(a) Group by
(b) Sort
(c) Arrange by
(d) Order by
19. If you want to exclude duplicate values from the aggregate function results, use the
_______ keyword.
(a) Primary key
(b) Unique
3
(c) DISTINCT
(d) COMMON
20. The string function that returns the index of the first occurrence of substring
is______________.
(a) INSERT()
(b) INSTR()
(c) INSRING()
(d) SUBSTR()

V. SECTION-B

1. What is the difference between char and varchar?

2. Explain the following SQL Constraints:

i. NOT NULL
ii. UNIQUE
iii. DEFAULT
iv. PRIMARY KEY

v. FOREIGN KEY

3. What is the difference between cardinality and degree?.


4. Differentiate between WHERE and HAVING clause.

5. Define Primary Key of a relation in SQL. Give an Example using a dummy table.

6. Differentiate between DDL and DML with one Example each.

7. Define RDBMS. Name any two RDBMS software.

8. Write any two differences between Single_row functions and Aggregate functions.

III. SECTION- C
1. Write SQL queries for the following :

Table : STIPEND

S_id Name Amount Subject Percentage Position


1 Anuj 4000 English 65 P1
2 Ashu 4500 History 60 P2
3 Ruby 3500 English 55 P2
4 Raman 3800 Math 58 P3
SQL Queries

4
a. Display the names of those students who has Position ‘P1’ sorted by NAME.

b. Display Name, Subject and Amount received in a year (as Annual Amount)
assuming that monthly amount is given in table.

c. Count the number of students whose percentage is less than 60.

d. Display the different subjects from the table.

e. Display the detail of student whose name ends with ‘j’

f. Display the subject wise amount paid.


Give the output of following SQL statement based on table STIPEND:

(i) Select MIN(Percentage) from Stipend where Subject=”English”;

(ii) Select SUM(Amount) from Stipend WHERE Position = ‘P2’;

(iii) Select AVG(Amount) from Stipend where Percentage>=60;

(iv) Select COUNT(distinct (SUBJECT)) from Stipend;

2. Write outputs for SQL queries which are based on the given table GARMENT:

i. SELECT GNAME, COLOUR FROM GARMENT WHERE SIZE = "M";


ii. SELECT GNAME, COLOUR FROM GARMENT WHERE PRICE > = 3000;
iii. SELECT PRICE FROM GARMENT WHERE COLOUR = "Blue";

3. Write the SQL functions which will perform the following operations:

i) To display the month name of the current date

ii) To remove leading spaces from the string,“ PYTHON“.

iii) To display the current date.

5
iv) To display your name in upper case.

v) To compute the remainder of division between two numbers, n1 and n2.

4. Consider a table SALES with the following data:

TABLE: SALES

Write SQL queries using SQL functions to perform the following operations:

i. Display the name of salesman in lower case.

ii. Display the year name for the date of join of salesman.

iii. Display the name of the weekday for the date of join of salesman whose month is 12.

6
iv. Display the highest salary of salesman having name length more than 15 and who gets
bonus.

*********

You might also like