Launch your tech mastery with us—your coding journey starts now!
Course Content
Introduction to MySQL
0/1
Installation and Setup of MySQL
0/1
MySQLData Types
0/1
MySQL Table Operations
0/1
MySQL Indexes and Keys
0/1
MySQL Views
0/1
MySQL Transactions
0/1
User Management and Security in MySQL
0/1
Backup and Restore in MySQL
0/1
MySQL

These help test your theoretical understanding of MySQL.

Sample Questions:

Q1. Which command is used to remove all records from a table but not the structure?

  1. DROP TABLE
    B. DELETE
    C. TRUNCATE ✅
     D. REMOVE

Q2. Which constraint ensures a column cannot contain NULL values?

  1. UNIQUE
    B. DEFAULT
    C. NOT NULL ✅
     D. INDEX

Q3. Which command is used to create a new database in MySQL?
 A. MAKE DATABASE
 B. CREATE DB
 C. NEW DATABASE
 D. CREATE DATABASE ✅

Q4. What does the AUTO_INCREMENT attribute do?
 A. Automatically updates column values
 B. Increments string values
 C. Generates unique numeric values ✅
 D. Deletes duplicate entries

Q5. What is the default port for MySQL?
 A. 80
 B. 1433
 C. 3306 ✅
 D. 1521

Q6. Which MySQL statement is used to retrieve data?
 A. FETCH
 B. EXTRACT
 C. GET
 D. SELECT ✅

Q7. Which of the following is a valid data type in MySQL?
 A. number
 B. integer
 C. INT ✅
 D. num

Q8. Which keyword is used to filter rows?
 A. GROUP BY
 B. ORDER BY
 C. WHERE ✅
 D. SELECT

Q9. What is the result of: SELECT 3 + 5;
 A. 8 ✅
 B. 35
 C. 53
 D. NULL

Q10. VARCHAR(100) means:
 A. Fixed 100 characters
 B. Variable up to 100 characters ✅
 C. Exactly 100 words
 D. Integer limit

Q11. Which clause is used to remove duplicate rows?
 A. REMOVE
 B. GROUP BY
 C. DISTINCT ✅
 D. UNIQUE

Q12. Which statement is used to change a table structure?
 A. CHANGE TABLE
 B. MODIFY
 C. ALTER TABLE ✅
 D. RENAME

Q13. Which clause is used to sort records in SQL?
 A. SORT
 B. ORDER BY ✅
 C. GROUP BY
 D. RANK

Q14. Which of the following statements is used to delete a table completely?
 A. REMOVE TABLE
 B. DELETE TABLE
 C. DROP TABLE ✅
 D. ERASE

Q15. What is a FOREIGN KEY used for?
 A. To encrypt data
 B. To link records across tables ✅
 C. To create indexes
 D. To make a column unique

Q16. Which keyword is used to rename a column or table?
 A. MODIFY
 B. UPDATE
 C. RENAME ✅
 D. REPLACE

Q17. Which aggregate function is used to get the number of records?
 A. TOTAL
 B. COUNT ✅
 C. SUM
 D. LENGTH

Q18. Which operator is used to compare a value to a list of values?
 A. LIKE
 B. MATCHES
 C. IN ✅
 D. BETWEEN

Q19. What does NULL mean in MySQL?
 A. 0
 B. Blank
 C. Unknown or missing value ✅
 D. Empty string

Q20. Which clause is used after GROUP BY to filter groups?
 A. WHERE
 B. HAVING ✅
 C. FILTER
 D. SELECT

Q21. Which function returns the current date and time in MySQL?
 A. TIME()
 B. SYSDATE()
 C. NOW() ✅
 D. DATE()

Q22. What is a view in MySQL?
 A. A stored function
 B. A backup table
 C. A virtual table ✅
 D. A schema

Q23. Which command is used to back up a MySQL database?
 A. mysqlbackup
 B. mysql_export
 C. mysqldump ✅
 D. mysql_restore

Q24. Which function calculates average value?
 A. MEAN
 B. AVG ✅
 C. AVERAGE
 D. MID

Q25. What is the purpose of a trigger?
 A. Manual insert
 B. Generate key
 C. Automatically execute on event ✅
 D. Compile SQL

Q26. Which command will show all databases?
 A. LIST DATABASES
 B. GET DATABASES
 C. SHOW DATABASES ✅
 D. SHOW ALL

Q27. What is the result of ROUND(5.6789, 2)?
 A. 5.6
 B. 5.67
 C. 5.68 ✅
 D. 5.679

Q28. Which clause is used to limit the number of returned rows?
 A. MAX
 B. RANGE
 C. LIMIT ✅
 D. SIZE

Q29. A UNIQUE constraint:
 A. Allows NULL and ensures no duplicates ✅
 B. Prevents NULL and duplicates
 C. Is same as PRIMARY KEY
 D. Can only be used on strings

Q30. The keyword EXISTS is used for:
 A. Checking table presence
 B. Checking if a subquery returns any rows ✅
 C. Joining tables
 D. Checking schema

Q31. Which JOIN returns all records from both tables, matching where possible?
 A. INNER JOIN
 B. LEFT JOIN
 C. FULL OUTER JOIN ✅
 D. RIGHT JOIN

Q32. Which command revokes privileges from a user?
 A. REVOKE ✅
 B. DENY
 C. REMOVE
 D. BLOCK

Q33. Which MySQL engine supports transactions?
 A. MyISAM
 B. ARCHIVE
 C. InnoDB ✅
 D. MEMORY

Q34. What is the correct syntax to delete a column?
 A. REMOVE COLUMN
 B. DELETE COLUMN
 C. ALTER TABLE table_name DROP COLUMN col_name; ✅
 D. MODIFY COLUMN

Q35. What does SET autocommit = 0; do?
 A. Enables backup
 B. Prevents table deletion
 C. Turns off automatic commit ✅
 D. Starts replication

Q36. The LIKE operator is used for:
 A. Arithmetic
 B. Exact matching
 C. Pattern matching ✅
 D. JOINs

Q37. Which function gets the number of characters in a string?
 A. LEN
 B. COUNT
 C. LENGTH ✅
 D. CHARCOUNT

Q38. REPLACE INTO works like:
 A. INSERT
 B. INSERT + DELETE
 C. UPSERT ✅
 D. UPDATE

Q39. Which of these can be used inside a trigger?
 A. COMMIT
 B. ROLLBACK
 C. INSERT ✅
 D. SELECT INTO

Q40. GRANT SELECT ON db.* TO ‘user’@’localhost’;
 A. Creates a user
 B. Gives read access ✅
 C. Drops a role
 D. Denies write access

Q41. Which format is used for MySQL binary log?
 A. JSON
 B. CSV
 C. BIN ✅
 D. XML

Q42. Which command shows active connections?
 A. SHOW USERS
 B. SHOW PROCESSLIST ✅
 C. CURRENT_USERS
 D. SYSTEM STATUS

Q43. What is partitioning in MySQL?
 A. Database design
 B. Dividing tables into logical parts ✅
 C. Normalization
 D. Clustering

Q44. Which is not allowed inside a MySQL function?
 A. SELECT
 B. RETURN
 C. UPDATE ✅
 D. DECLARE

Q45. What is the difference between DELETE and TRUNCATE?
 A. DELETE is faster
 B. TRUNCATE logs individual rows
 C. DELETE can be rolled back, TRUNCATE cannot ✅
 D. TRUNCATE is DML

Q46. Which of the following is a DDL command?
 A. INSERT
 B. UPDATE
 C. CREATE ✅
 D. SELECT

Q47. What will this return: SELECT MOD(10, 3);
 A. 3
 B. 10
 C. 1 ✅
 D. 0

Q48. What does SHOW CREATE TABLE table_name; do?
 A. Shows all rows
 B. Recreates the table
 C. Shows the SQL used to create the table ✅
 D. Describes the table

Q49. Which MySQL statement is used to undo a transaction?
 A. ROLLBACK ✅
 B. STOP
 C. CANCEL
 D. EXIT

Q50. What is the default user in MySQL?
 A. admin
 B. mysql
 C. user
 D. root ✅