MCQs of MySQL
MCQs of MySQL
1. MySQL is a /an
a. Relational Database b. Database
c. RDBMS d. Table
2. USE <databasename> command
a. is not used in MySQL b. is given before quitting MySQL
c. opens a table d. opens a database
3. Number of columns in a table is called
a. Power b. Degree
c. Cardinality d. Design
4. A database
a. Contains tables b. Is a part of a table
c. Is same as a table d. Removes data from a table
5. Number of rows in a table is called
a. Power b. Degree
c. Cardinality d. Design
6. ORDER BY clause is used to sort data
a. in ascending order b. in desceding order
c. both (a) and (b) d. None of the above
7. A table can have
a. Only one candidate key b. Only one primary key
c. Only one alternate key d. No alternate key
8. Wild card characters are used
a. In LIKE clause b. In ORDER BY clause
c. In BETWEEN clause d. In IN clause
9. DDL is
a. a part of SQL b. a part of DML
c. a part of DCL d. None of the above
10. LIKE clause is used
a. For pattern matching b. For table matching
c. For inserting similar data in a table d. For deleting data from a table
MySQL - REVISION TOUR
LAB EXERCISES From MySQL
Consider a database LOANS with the following table:
Table: Loan_Accounts
AccNo Cust_Name Loan_Amount Instalments Int_Rate Start_Date Interest
1 R.K. Gupta 300000 36 12.00 19-07-2009
2 S.P. Sharma 500000 48 10.00 22-03-2008
3 K.P. Jain 300000 36 NULL 08-03-2007
4 M.P. Yadav 800000 60 10.00 06-12-2008
5 S.P. Sinha 200000 36 12.50 03-01-2010
6 P. Sharma 700000 60 12.50 05-06-2008
7 K.S. Dhall 500000 48 NULL 05-03-2008
90/1 (Near Pd. Madan Mohan Malviya Hospital), Malviya Nagar, New.Delhi-110017 Page 1
THE SUCCESS POINT®
A point where success begins……
Write SQL commands for the tasks 1 to 35 and write the output for the SQL commands
36
to 40:
Create Database and use it
1. Create the database LOANS.
2. Use the database LOANS.
Create Table / Insert Into
3. Create the table Loan_Accounts and insert tuples in it.
Simple Select
4. Display the details of all the loans.
5. Display the AccNo, Cust_Name, and Loan_Amount of all the loans.
Conditional Select using Where Clause
6. Display the details of all the loans with less than 40 instalments.
7. Display the AccNo and Loan_Amount of all the loans started before 01-04-2009.
8. Display the Int_Rate of all the loans started after 01-04-2009.
VISION TOUR
Using NULL
9. Display the details of all the loans whose rate of interest is NULL.
10. Display the details of all the loans whose rate of interest is not NULL.
Using DISTINCT Clause
11. Display the amounts of various loans from the table Loan_Accounts. A loan amount
should appear only once.
12. Display the number of instalments of various loans from the table Loan_Accounts. An
instalment should appear only once..
Using Logical Operators (NOT, AND, OR)
13. Display the details of all the loans started after 31-12-2008 for which the number of
instalments are more than 36.
14. Display the Cust_Name and Loan_Amount for all the loans which do not have number
of instalments 36.
15. Display the Cust_Name and Loan_Amount for all the loans for which the loan amount
is less than 500000 or int_rate is more than 12.
16. Display the details of all the loans which started in the year 2009.
17. Display the details of all the loans whose Loan_Amount is in the range 400000 to
500000.
18. Display the details of all the loans whose rate of interest is in the range 11% to 12%.
Using IN Operator
19. Display the Cust_Name and Loan_Amount for all the loans for which the number of
instalments are 24, 36, or 48. (Using IN operator)
Using BETWEEN Operator
20. Display the details of all the loans whose Loan_Amount is in the range 400000 to
500000. (Using BETWEEN operator)
21. Display the details of all the loans whose rate of interest is in the range 11% to 12%.
(Using BETWEEN operator)
L - REVISION TOUR
Using LIKE Operator
22. Display the AccNo, Cust_Name, and Loan_Amount for all the loans for which the
90/1 (Near Pd. Madan Mohan Malviya Hospital), Malviya Nagar, New.Delhi-110017 Page 2
THE SUCCESS POINT®
A point where success begins……
90/1 (Near Pd. Madan Mohan Malviya Hospital), Malviya Nagar, New.Delhi-110017 Page 3