MySQL questions for interview preparation


Q10: What is the usage of ENUMs in MySQL?

Ans: String objects are ENUMs. By creating ENUMs, we allow the end-user to submit proper input because if the user gives information that is not part of the ENUM specified data, the query will not run. An error message stating "The incorrect Query" will be presented. For example, imagine we wish to take the user's gender as an input, so we define ENUM('male,' 'female,' 'other'). Therefore, anytime the user attempts to input any string other than these three, an error occurs. ENUMs are used to limit the potential values that may be entered into the table:
CREATE TABLE months (month ENUM 'January', 'February', 'March'); INSERT months VALUES ('April').

Q11: What are the MySQL clients and utilities?

Ans: There are several MySQL applications available to assist you in communicating with the server. Some of the essential administrative responsibilities are mentioned below:

  • MySQL—   An interactive software that allows you to send SQL queries to the server and examine the results. Mysql may also be used to run batch scripts (text files containing SQL statements).
  • mysqladmin—  An administrative application used to conduct activities such as shutting down the server, verifying its settings, and monitoring its status if it appears to be malfunctioning.
  • mysqldump—  A tool for backing up and transferring databases to another server.
  • mysqlcheck and myisamchk—  Table inspection, analysis, and optimization programs and fixes if tables become damaged. mysqlcheck supports MyISAM tables and, to a lesser extent, tables for other storage engines. myisamchk can only be used with MyISAM tables.

Q12: What is a transaction? Describe MySQL transaction properties.

Ans:  A transaction is a set of database actions that are performed as a single entity. If any of the transactional duties are left unfinished, the transaction will fail. As a result, for a transaction to be successful, all of its duties must be completed. A transaction has four qualities known as the ACID property. These characteristics are discussed more below.

  • Atomicity:  guarantees that all tasks in a transaction are performed successfully; otherwise, all completed activities are rolled back to the prior state in the event of a failure.
  • Consistency:   It guarantees that the database state is correctly updated for the committed transaction.
  • Isolation:   It guarantees that all tasks associated with a transaction are completed independently and openly.
  • Durability:  It assures that all committed transactions are consistent in the event of a system failure.

Q13: What is a LIKE statement? Explain % and _ in LIKE.

Ans: Conditions may require a pattern to detect when utilizing filters in operations like SELECT, UPDATE, and DELETE. LIKE is utilized to do this.. LIKE has two wildcard characters, namely % (percentage) and _ (underscore). Percentage(%) matches a string of characters, while underscore matches a single character. 

For example, %t will detect trees and tea both. However, _t will only detect one extra character, i.e., strings like ti or te. 

Q14: What is a storage engine? What are the differences between InnoDB and MyISAM engines?

Ans: The storage engine, which is used to perform many sorts of database operations, is a key component of the MySQL server. Each database table that is produced is dependent on the storage engine. MySQL offers two types of storage engines: transactional and non-transactional storage engines. InnoDB is MySQL's transactional storage engine by default. Non-transactional storage engines include the MyISAM storage engine.

The following sections compare and contrast the InnoDB and MyISAM storage engines:

  • MyISAM supports the FULLTEXT index. However, it is not supported by InnoDB.
  • MyISAM performs better than InnoDB.
  • Unlike MyISAM, InnoDB supports the ACID (Atomicity, Consistency, Isolation, and Durability) characteristic.
  • Row-level locking is supported by InnoDB, whereas MyISAM supports table-level locking.
  • InnoDB is best suited for large databases, whereas MyISAM is best suited for small databases.

Q15: Why do we use the MySQL database server?

Ans: The MYSQL server is free to use for developers and small businesses. MySQL is a free and open-source database server. MySQL's community is huge and helpful. Thus any issues with MySQL are handled as soon as feasible. Because MySQL has been on the market for a long time, there are highly stable versions available. All issues found in earlier versions have been continually eliminated, and each upgrade provides a highly stable version. The MySQL database server is extremely fast, dependable, and simple to use. The program is simple to use and customize. MySQL software is available for free download on the internet.