mysql banner

MySQL Multiple Choice Questions (MCQs) and Answers

Master MySQL with Practice MCQs. Explore our curated collection of Multiple Choice Questions. Ideal for placement and interview preparation, our questions range from basic to advanced, ensuring comprehensive coverage of MySQL concepts. Begin your placement preparation journey now!

Q91

Q91 Spot the error in this SQL statement:
CREATE VIEW SalesSummary AS SELECT ProductID, SUM(Quantity) FROM Sales GROUP BY ProductID HAVING SUM(Quantity) > 100;

A

Missing alias for SUM(Quantity)

B

Syntax is correct

C

HAVING clause is unnecessary

D

Grouping by ProductID is not allowed

Q92

Q92 What is a transaction in database management?

A

A group of SQL queries executed individually

B

A group of SQL queries executed as a single unit of work

C

A single SQL query

D

A schema in the database

Q93

Q93 Which statement is used to start a transaction in MySQL?

A

BEGIN TRANSACTION

B

START TRANSACTION

C

INITIATE TRANSACTION

D

BEGIN

Q94

Q94 What does the COMMIT statement do?

A

Reverts the current transaction

B

Starts a new transaction

C

Saves the changes made by the current transaction

D

Checks the integrity of the transaction

Q95

Q95 What is the role of the ROLLBACK statement in a transaction?

A

To duplicate the transaction

B

To save the transaction

C

To undo the transaction if an error occurs

D

To start over the database connection

Q96

Q96 In which case would you use the SAVEPOINT statement in a transaction?

A

To save the transaction to disk

B

To mark a specific point within a transaction to which you later might rollback

C

To split the transaction

D

To end the transaction

Q97

Q97 How does a transaction ensure data integrity?

A

By locking the database

B

By allowing multiple users to modify data simultaneously

C

By ensuring all parts of the transaction succeed or fail together

D

By prioritizing transactions

Q98

Q98 What is the effect of this SQL command?
SET AUTOCOMMIT = 0;

A

Turns off automatic execution of statements

B

Turns on automatic saving of the transaction

C

Disables the transaction log

D

Turns off automatic committing of transactions

Q99

Q99 Consider this sequence of commands:
START TRANSACTION; INSERT INTO Orders (Product, Quantity) VALUES ('Shoes', 10); ROLLBACK;
What is the outcome?

A

The order is permanently added to the database

B

The order is not added to the database

C

The order data is corrupted

D

A new transaction is started

Q100

Q100 How do transactions affect performance in a database system?

A

They slow down database operations due to locking mechanisms

B

They generally speed up database operations

C

They have no impact on performance

D

They improve data integrity without affecting performance

Q101

Q101 Identify the error in this SQL transaction sequence:
BEGIN; UPDATE Account SET Balance = Balance - 100 WHERE ID = 1; COMMIT;

A

Incorrect use of BEGIN for starting a transaction

B

Syntax error in UPDATE statement

C

COMMIT does not save the changes

D

No error

Q102

Q102 What's wrong with this transaction sequence?
START TRANSACTION; DELETE FROM Orders; COMMIT;

A

Missing WHERE clause in DELETE statement, potentially dangerous

B

No error

C

COMMIT should be ROLLBACK

D

DELETE statement syntax error

Q103

Q103 What is the purpose of using SSL in MySQL connections?

A

To speed up the connection

B

To compress data before transmission

C

To encrypt data during transmission

D

To log connection activities

Q104

Q104 What does the MySQL SECURITY command do when applied to a view?

A

Changes the view's charset

B

Sets who can access the view

C

Deletes the view after a certain period

D

Modifies the view's collation setting

Q105

Q105 How can you restrict user access to specific columns in a MySQL table?

A

By setting column-level privileges

B

By deleting unwanted columns

C

By using table-level firewalls

D

By encrypting specific columns

Q106

Q106 What is the primary benefit of implementing database auditing in MySQL?

A

To increase data retrieval speed

B

To monitor and log database activity

C

To reduce database size

D

To automatically fix database errors

Q107

Q107 What does this SQL command achieve?
REVOKE ALL PRIVILEGES ON database.* FROM 'user'@'localhost';

A

Grants all privileges to a user

B

Removes all privileges from a user for a database

C

Changes the user's password

D

None of the above

Q108

Q108 How does enabling the require_secure_transport option in MySQL enhance security?

A

Forces connections to use SSH

B

Forces connections to use SSL/TLS

C

Disables all database connections

D

Increases connection timeout

Q109

Q109 Identify the error in this user creation SQL command:
CREATE USER 'admin'@'localhost' IDENTIFIED BY password;

A

Syntax is correct

B

Missing quotes around 'password'

C

Wrong host specified

D

Password is too simple

Q110

Q110 What's wrong with using the following SQL statement for password management?
SET PASSWORD FOR 'user'@'localhost' = PASSWORD('open_sesame');

A

Depreciated method for setting passwords

B

Syntax error

C

No error

D

Incorrect hostname usage

Q111

Q111 What is the purpose of the mysqldump utility?

A

To compress MySQL databases

B

To replicate databases

C

To back up MySQL databases

D

To optimize MySQL databases

Q112

Q112 What type of backup involves copying only the data changed since the last full backup?

A

Incremental backup

B

Full backup

C

Mirror backup

D

Snapshot backup

Q113

Q113 Which statement is true about point-in-time recovery in MySQL?

A

It requires binary logging to be enabled

B

It can only restore data deleted by mistake

C

It’s only possible with mysqldump

D

It is automatically enabled in MySQL

Q114

Q114 What is the main advantage of using physical backups over logical backups in MySQL?

A

Faster restoration times

B

More secure

C

Smaller backup files

D

Easier to configure

Q115

Q115 What does the following command do?
mysqladmin -u root -p flush-logs

A

Deletes all logs

B

Creates a new log file by closing and reopening the log files

C

Restarts the MySQL server

D

Changes log file permissions

Q116

Q116 How do you restore a MySQL database from a dump file created by mysqldump?

A

mysql -u user -p database < dump.sql

B

mysqldump -u user -p database < dump.sql

C

mysqladmin -u user -p database < dump.sql

D

mysqlrestore -u user -p database < dump.sql

Q117

Q117 What is the impact of enabling the --single-transaction option during a mysqldump of an InnoDB database?

A

Creates a new transaction for each table

B

Locks the entire database during the dump

C

Creates a consistent snapshot without locking tables

D

Disables logging during the dump

Q118

Q118 Identify the error in this backup command:
mysqldump -u root -p --all-databases > backup.sql

A

Incorrect redirection for output

B

Syntax error in options

C

No error

D

Incorrect user credentials

Q119

Q119 What's wrong with using the following command for a backup?
mysqldump -u root --all-databases --quick > backup.sql

A

The --quick option is not appropriate for all databases

B

No error

C

The command should not use redirection

D

The command lacks password authentication

Q120

Q120 What is load balancing in the context of MySQL?

A

Distributing user requests across multiple servers

B

Splitting databases across servers

C

Replicating databases across multiple locations

D

Synchronizing data across servers

ad verticalad vertical
ad