100 MySQL MCQ (Multiple Choice Questions) with Answers

1) Which of the following is an open-source Relational Database Management System (RDBMS)?
  1. MongoDB
  2. MySQL
  3. Cassandra
  4. Redis
Show Answer
Answer: b


2) Which SQL command is used to retrieve data from a MySQL database?

  1. FETCH
  2. GET
  3. SELECT
  4. EXTRACT
Show Answer
Answer: c


3) Which data type is used to store variable-length character strings in MySQL?

  1. CHAR
  2. VARCHAR
  3. TEXT
  4. STRING
Show Answer
Answer: b


4) Which clause is used to filter rows based on a specified condition in a SELECT query?

  1. HAVING
  2. WHERE
  3. GROUP BY
  4. ORDER BY
Show Answer
Answer: b


5) What is the default port number for MySQL connections?

  1. 1433
  2. 1521
  3. 3306
  4. 5432
Show Answer
Answer: c


6) Which SQL keyword is used to remove duplicate rows from a result set?

  1. UNIQUE
  2. DISTINCT
  3. DIFFERENT
  4. FILTER
Show Answer
Answer: b


7) Which command is used to add a new record into a MySQL table?

  1. ADD RECORD
  2. INSERT INTO
  3. UPDATE
  4. CREATE ROW
Show Answer
Answer: b


8) Which statement is used to modify existing records in a table?

  1. MODIFY
  2. ALTER
  3. UPDATE
  4. CHANGE
Show Answer
Answer: c


9) Which command is used to delete all rows from a table without logging individual row deletions?

  1. DELETE
  2. REMOVE
  3. TRUNCATE
  4. DROP
Show Answer
Answer: c


10) Which command permanently deletes a table structure along with all its data?

  1. TRUNCATE TABLE
  2. DROP TABLE
  3. DELETE TABLE
  4. REMOVE TABLE
Show Answer
Answer: b


11) Which SQL constraint ensures that all values in a column are unique?

  1. CHECK
  2. NOT NULL
  3. UNIQUE
  4. PRIMARY KEY
Show Answer
Answer: c


12) A PRIMARY KEY constraint automatically implies which combination of constraints?

  1. UNIQUE and CHECK
  2. NOT NULL and DEFAULT
  3. UNIQUE and NOT NULL
  4. FOREIGN KEY and UNIQUE
Show Answer
Answer: c


13) How many PRIMARY KEY constraints can a single table have?

  1. 0
  2. 1
  3. 2
  4. Unlimited
Show Answer
Answer: b


14) Which SQL clause is used to sort the result set in ascending or descending order?

  1. SORT BY
  2. GROUP BY
  3. ORDER BY
  4. ALIGN BY
Show Answer
Answer: c


15) What is the default sorting direction of the ORDER BY clause?

  1. DESC
  2. ASC
  3. RANDOM
  4. NONE
Show Answer
Answer: b


16) Which wildcard character represents zero, one, or multiple characters in a LIKE query?

  1. _
  2. %
  3. *
  4. #
Show Answer
Answer: b


17) Which wildcard character represents a single character in a LIKE query?

  1. %
  2. _
  3. ?
  4. $
Show Answer
Answer: b


18) Which aggregate function returns the total number of rows matching a criteria?

  1. SUM()
  2. TOTAL()
  3. COUNT()
  4. NUMBER()
Show Answer
Answer: c


19) Which operator is used to search for a specified pattern in a column?

  1. IN
  2. LIKE
  3. BETWEEN
  4. EXISTS
Show Answer
Answer: b


20) Which clause is used to group rows that have the same values in specified columns?

  1. ORDER BY
  2. GROUP BY
  3. HAVING
  4. JOIN
Show Answer
Answer: b


21) Which clause is used to filter groups created by the GROUP BY clause?

  1. WHERE
  2. HAVING
  3. FILTER
  4. LIKE
Show Answer
Answer: b


22) Which function returns the current date and time in MySQL?

  1. CURDATE()
  2. NOW()
  3. GETDATE()
  4. TODAY()
Show Answer
Answer: b


23) Which JOIN returns all records from the left table and matched records from the right table?

  1. INNER JOIN
  2. RIGHT JOIN
  3. LEFT JOIN
  4. FULL JOIN
Show Answer
Answer: c


24) Which JOIN returns records that have matching values in both tables?

  1. LEFT JOIN
  2. RIGHT JOIN
  3. INNER JOIN
  4. CROSS JOIN
Show Answer
Answer: c


25) What type of JOIN produces a Cartesian product of two tables?

  1. INNER JOIN
  2. CROSS JOIN
  3. OUTER JOIN
  4. SELF JOIN
Show Answer
Answer: b


26) Which MySQL storage engine supports transactions and foreign keys by default?

  1. MyISAM
  2. Memory
  3. InnoDB
  4. CSV
Show Answer
Answer: c


27) Which SQL statement is used to create a new database?

  1. MAKE DATABASE
  2. CREATE DATABASE
  3. NEW DATABASE
  4. BUILD DATABASE
Show Answer
Answer: b


28) Which statement is used to select a database to work with in MySQL?

  1. USE database_name;
  2. OPEN database_name;
  3. SELECT database_name;
  4. CONNECT database_name;
Show Answer
Answer: a


29) Which statement shows all available databases in MySQL?

  1. DISPLAY DATABASES;
  2. SHOW DATABASES;
  3. LIST DATABASES;
  4. GET DATABASES;
Show Answer
Answer: b


30) Which statement displays the structure of a table (columns, types, keys)?

  1. SHOW STRUCTURE table_name;
  2. DESCRIBE table_name;
  3. INFO table_name;
  4. STRUCT table_name;
Show Answer
Answer: b


31) Which command is used to add a new column to an existing table?

  1. UPDATE TABLE table_name ADD column_name;
  2. ALTER TABLE table_name ADD column_name datatype;
  3. MODIFY TABLE table_name ADD column_name;
  4. INSERT INTO table_name COLUMN column_name;
Show Answer
Answer: b


32) Which operator is used to test for NULL values in MySQL?

  1. = NULL
  2. IS NULL
  3. EQUALS NULL
  4. == NULL
Show Answer
Answer: b


33) Which SQL function replaces NULL with a specified value?

  1. IFNULL()
  2. ISNULL()
  3. NULLIF()
  4. NVL()
Show Answer
Answer: a


34) What does the auto_increment attribute do in MySQL?

  1. Automatically decreases column value
  2. Automatically generates a unique numeric value for new rows
  3. Automatically backs up the table
  4. Encrypts primary keys
Show Answer
Answer: b


35) Which keyword is used to limit the number of rows returned by a query in MySQL?

  1. TOP
  2. LIMIT
  3. ROWNUM
  4. FETCH FIRST
Show Answer
Answer: b


36) In LIMIT 10, 5, what does 10 represent?

  1. The number of rows to fetch
  2. The starting row offset
  3. The step size
  4. The max ID
Show Answer
Answer: b


37) Which function is used to convert text to uppercase in MySQL?

  1. UPPER()
  2. UCASE()
  3. BOTH a and b
  4. TOUPPER()
Show Answer
Answer: c


38) Which function returns the length of a string in characters?

  1. LENGTH()
  2. CHAR_LENGTH()
  3. STRLEN()
  4. SIZE()
Show Answer
Answer: b


39) Which mathematical function returns the highest value from a column?

  1. HIGHEST()
  2. MAX()
  3. TOP()
  4. GREATEST()
Show Answer
Answer: b


40) Which operator is used to filter values within an inclusive range?

  1. IN
  2. BETWEEN
  3. WITHIN
  4. RANGE
Show Answer
Answer: b


41) Which operator allows specifying multiple discrete values in a WHERE clause?

  1. IN
  2. MULTI
  3. OR
  4. LIKE
Show Answer
Answer: a


42) What is the purpose of a Foreign Key in MySQL?

  1. Ensures unique values in the same table
  2. Prevents duplicate records
  3. Enforces referential integrity between two tables
  4. Automatically indexes text columns
Show Answer
Answer: c


43) Which command grants privileges to MySQL users?

  1. GIVE
  2. ALLOW
  3. GRANT
  4. SET PRIVILEGE
Show Answer
Answer: c


44) Which command removes privileges from a MySQL user?

  1. REVOKE
  2. REMOVE
  3. DENY
  4. CANCEL
Show Answer
Answer: a


45) Which privilege allows a user to create new tables and databases?

  1. WRITE
  2. CREATE
  3. BUILD
  4. MAKE
Show Answer
Answer: b


46) Which command saves all pending transaction changes to the database?

  1. SAVE
  2. COMMIT
  3. ROLLBACK
  4. STORE
Show Answer
Answer: b


47) Which command undoes transaction changes made since the last commit?

  1. UNDO
  2. REVERT
  3. ROLLBACK
  4. CANCEL
Show Answer
Answer: c


48) Which MySQL log records all statements that change database data?

  1. Error Log
  2. Binary Log
  3. Slow Query Log
  4. General Query Log
Show Answer
Answer: b


49) What does DDL stand for in database terminology?

  1. Data Definition Language
  2. Data Description Language
  3. Data Design Language
  4. Dynamic Data Language
Show Answer
Answer: a


50) Which of the following is a DML command?

  1. CREATE
  2. ALTER
  3. INSERT
  4. DROP
Show Answer
Answer: c


51) Which of the following is a DDL command?

  1. UPDATE
  2. SELECT
  3. TRUNCATE
  4. DELETE
Show Answer
Answer: c


52) What is the result of SELECT 5 + NULL; in MySQL?

  1. 5
  2. 0
  3. NULL
  4. Error
Show Answer
Answer: c


53) Which function removes leading and trailing spaces from a string?

  1. STRIP()
  2. CLEAN()
  3. TRIM()
  4. REMOVE()
Show Answer
Answer: c


54) Which index type is created automatically when a PRIMARY KEY is defined?

  1. FULLTEXT
  2. SPATIAL
  3. Clustered Index
  4. Secondary Index
Show Answer
Answer: c


55) Which keyword is used to rename a column or table in a SELECT output?

  1. RENAME
  2. ALIAS
  3. AS
  4. NAME
Show Answer
Answer: c


56) Which function extracts the year part from a DATE or DATETIME expression?

  1. EXTRACT_YEAR()
  2. YEAR()
  3. GET_YEAR()
  4. DATE_YEAR()
Show Answer
Answer: b


57) How do you write a single-line comment in MySQL?

  1. // comment
  2. — comment
  3. # comment
  4. % comment
Show Answer
Answer: b


58) What is the purpose of the MySQL EXPLAIN keyword?

  1. Explains database user permissions
  2. Displays the execution plan of a query
  3. Generates query documentation
  4. Repairs corrupted tables
Show Answer
Answer: b


59) Which function is used to concatenate two or more strings together?

  1. COMBINE()
  2. CONCAT()
  3. MERGE()
  4. JOIN_STR()
Show Answer
Answer: b


60) What is a View in MySQL?

  1. A physical table saved on disk
  2. A virtual table based on the result-set of an SQL query
  3. A backup copy of a table
  4. An index file
Show Answer
Answer: b


61) Which command is used to create a view?

  1. MAKE VIEW view_name AS …
  2. CREATE VIEW view_name AS …
  3. BUILD VIEW view_name AS …
  4. NEW VIEW view_name AS …
Show Answer
Answer: b


62) What is a Stored Procedure in MySQL?

  1. A table designed for fast data storage
  2. A prepared SQL code that you can save and reuse
  3. A trigger executed on DELETE
  4. An automatic database backup script
Show Answer
Answer: b


63) Which SQL keyword is used to execute a Stored Procedure in MySQL?

  1. EXECUTE
  2. RUN
  3. CALL
  4. START
Show Answer
Answer: c


64) What is a MySQL Trigger?

  1. A manual backup command
  2. A stored program executed automatically in response to certain events on a table
  3. A primary key modifier
  4. A transaction log file
Show Answer
Answer: b


65) Which events can trigger a database trigger in MySQL?

  1. SELECT, INSERT, UPDATE
  2. INSERT, UPDATE, DELETE
  3. CREATE, ALTER, DROP
  4. GRANT, REVOKE, DENY
Show Answer
Answer: b


66) What does the CHAR data type store?

  1. Fixed-length string
  2. Variable-length string
  3. Large binary data
  4. Numerical integer values
Show Answer
Answer: a


67) What is the storage size of the TINYINT data type in bytes?

  1. 1 byte
  2. 2 bytes
  3. 4 bytes
  4. 8 bytes
Show Answer
Answer: a


68) What is the maximum range of signed values for a TINYINT column?

  1. 0 to 255
  2. -128 to 127
  3. -32768 to 32767
  4. -2147483648 to 2147483647
Show Answer
Answer: b


69) Which data type is best suited for storing monetary values with exact precision?

  1. FLOAT
  2. DOUBLE
  3. DECIMAL
  4. INT
Show Answer
Answer: c


70) What is the default string matching behavior in MySQL standard string queries?

  1. Case-sensitive
  2. Case-insensitive
  3. Binary matching only
  4. ASCII matching only
Show Answer
Answer: b


71) Which operator is used for bitwise AND operations in MySQL?

  1. &&
  2. AND
  3. &
  4. |
Show Answer
Answer: c


72) Which condition tests if a subquery returns any rows?

  1. IN
  2. EXISTS
  3. ANY
  4. SOME
Show Answer
Answer: b


73) Which set operator combines the results of two queries and removes duplicate rows?

  1. UNION ALL
  2. UNION
  3. JOIN
  4. INTERSECT
Show Answer
Answer: b


74) What is the difference between UNION and UNION ALL?

  1. UNION retains duplicates; UNION ALL removes duplicates
  2. UNION removes duplicates; UNION ALL retains duplicates
  3. UNION works on text; UNION ALL works on numbers
  4. There is no difference
Show Answer
Answer: b


75) Which function returns the current logged-in MySQL user and hostname?

  1. USER()
  2. CURRENT_USER()
  3. WHOAMI()
  4. BOTH a and b
Show Answer
Answer: d


76) Which command reloads the grant tables in MySQL?

  1. RELOAD PRIVILEGES;
  2. REFRESH GRANTS;
  3. FLUSH PRIVILEGES;
  4. UPDATE PRIVILEGES;
Show Answer
Answer: c


77) Which clause is used to assign default values to a column if no value is provided?

  1. SET
  2. DEFAULT
  3. AUTO
  4. PRESET
Show Answer
Answer: b


78) What does ACID stand for in transaction processing?

  1. Atomicity, Consistency, Isolation, Durability
  2. Accuracy, Control, Isolation, Data
  3. Availability, Consistency, Integrity, Durability
  4. Access, Control, Indexing, Data
Show Answer
Answer: a


79) Which engine storage type stores all data in RAM for fast access?

  1. InnoDB
  2. MyISAM
  3. Memory (HEAP)
  4. Archive
Show Answer
Answer: c


80) What command is used to delete a database in MySQL?

  1. REMOVE DATABASE db_name;
  2. DELETE DATABASE db_name;
  3. DROP DATABASE db_name;
  4. ERASE DATABASE db_name;
Show Answer
Answer: c


81) Which command is used to create an index on a table?

  1. MAKE INDEX
  2. CREATE INDEX
  3. ADD INDEX
  4. BUILD INDEX
Show Answer
Answer: b


82) What is the main purpose of creating an index on a table?

  1. To compress table size
  2. To speed up data retrieval operations
  3. To encrypt data
  4. To enforce foreign key limits
Show Answer
Answer: b


83) Which function calculates the average value of a numeric column?

  1. AVG()
  2. MEAN()
  3. AVERAGE()
  4. SUM_AVG()
Show Answer
Answer: a


84) Which statement returns all records from a table named employees?

  1. GET ALL FROM employees;
  2. SELECT * FROM employees;
  3. DISPLAY employees;
  4. FETCH ALL employees;
Show Answer
Answer: b


85) What does the ON DELETE CASCADE option mean for foreign keys?

  1. Dependent rows in the child table are automatically deleted when the parent row is deleted
  2. Prevents deletion of rows in the parent table
  3. Sets foreign key values to NULL upon parent deletion
  4. Archives deleted records to a backup table
Show Answer
Answer: a


86) Which function returns the current database name in use?

  1. CURRENT_DB()
  2. DATABASE()
  3. SHOW_DB()
  4. DB_NAME()
Show Answer
Answer: b


87) How do you write a multi-line comment in MySQL?

  1. // comment //
  2. /* comment */
  3. — comment —
  4. # comment #
Show Answer
Answer: b


88) Which data type is best used for storing binary large objects like images or files?

  1. VARCHAR
  2. TEXT
  3. BLOB
  4. CLOB
Show Answer
Answer: c


89) What is the default date format in MySQL?

  1. DD-MM-YYYY
  2. MM-DD-YYYY
  3. YYYY-MM-DD
  4. YYYY-DD-MM
Show Answer
Answer: c


90) Which function is used to get the number of days between two dates?

  1. DATEDIFF()
  2. DATE_DIFF()
  3. SUBDATE()
  4. DIFFDATE()
Show Answer
Answer: a


91) What does the CHECK constraint do in MySQL?

  1. Verifies if a user has admin access
  2. Ensures that values in a column satisfy a specific condition
  3. Checks database integrity on startup
  4. Verifies duplicate keys
Show Answer
Answer: b


92) Which character set is recommended in modern MySQL for full Unicode support (including emojis)?

  1. latin1
  2. utf8mb3
  3. utf8mb4
  4. ascii
Show Answer
Answer: c


93) Which statement is used to remove an index named idx_name from table_name?

  1. DROP INDEX idx_name ON table_name;
  2. DELETE INDEX idx_name FROM table_name;
  3. REMOVE INDEX idx_name;
  4. ALTER TABLE table_name CLEAR INDEX idx_name;
Show Answer
Answer: a


94) Which clause limits query results based on aggregate calculations?

  1. WHERE
  2. ORDER BY
  3. HAVING
  4. GROUP BY
Show Answer
Answer: c


95) What is a subquery in MySQL?

  1. A query stored as a view
  2. A query nested inside another SQL statement
  3. A secondary database connection
  4. A procedure call
Show Answer
Answer: b


96) Which command shows all active threads/queries running in MySQL?

  1. SHOW PROCESSLIST;
  2. SHOW THREADS;
  3. SHOW QUERIES;
  4. LIST PROCESSES;
Show Answer
Answer: a


97) Which clause is used to set savepoints inside a transaction?

  1. CREATE SAVEPOINT name;
  2. SAVEPOINT name;
  3. SET SAVEPOINT name;
  4. POINT name;
Show Answer
Answer: b


98) Which MySQL system variable stores the auto-increment step value?

  1. auto_increment_step
  2. auto_increment_increment
  3. auto_increment_offset
  4. increment_val
Show Answer
Answer: b


99) Which function returns the auto-generated ID from the last INSERT statement executed by the connection?

  1. LAST_INSERT_ID()
  2. GET_LAST_ID()
  3. AUTO_ID()
  4. NEW_ID()
Show Answer
Answer: a


100) What does the COALESCE() function return?

  1. The first non-NULL value in a list of arguments
  2. The sum of all non-NULL values
  3. A count of NULL entries
  4. The last argument regardless of NULL status
Show Answer
Answer: a

 

100 SQL MCQ (Multiple Choice Questions) with Answers
100 MongoDB MCQ (Multiple Choice Questions) with Answers
Studyopedia Editorial Staff
contact@studyopedia.com

We work to create programming tutorials for all.

No Comments

Post A Comment