MySQL Interview Questions and Answers

Last updated on Feb 07, 2024
  • Share
MySQL Interview Questions

MYSQL is one of the most successful and leading pathways toward data administration careers. You will be amazed to know that this database service holds a total of 46.83% share in the relational database market. So to make your career and prepare for interviews in this field would be a good choice. Today we will help with these interviews by providing you with some MYSQL Interview Questions and Answers. MYSQL is one of the most popular database technologies used in the database industry. Popular companies like Microsoft, Amazon, Oracle, and IBM are using this technology on a vast basis to manage and store their data. According to one survey, nowadays more than 90% of organizations are using OSDBMS i.e. Open Source Database Management System. But to handle this database, professionals must know the MYSQL programming language.

Quick Facts About MySQL
What is the latest version of MySQL? 8.0.22 released in 19th October 2020
When was MySQL first released? 23 May 1995
Who developed MySQL? Oracle Corporation.
What language does MySQL use? C and C++ language
About License GNU Public License
Official Website https://www.mysql.com

MySQL Query Interview Questions

Here in this article, we will be listing frequently asked MySQL Interview Questions and Answers with the belief that they will be helpful for you to gain higher marks. Also, to let you know that this article has been written under the guidance of industry professionals and covered all the current competencies.

Q61. Write a query to fetch duplicate records from a table using MySQL?
Answer

SELECT EmpId, Project, Salary, COUNT(*) FROM EmployeeSalary GROUP BY EmpId, Project, Salary HAVING COUNT(*) > 1;

Q62. Write a query to fetch common records between two tables using MySQL?
Answer
Using INTERSECT

SELECT * FROM EmployeeSalary
INTERSECT
SELECT * FROM ManagerSalary

 

Q63. What is the difference between having and where clause in Mysql? Explain
Answer

WHERE term is used for filtering rows, and it applies to every row but HAVING term is used to filter groups.

WHERE can be used without the GROUP BY but HAVING clause cannot be used without the GROUP BY.

Q64. What is constraints? Also explain the different types of constraints?
Answer

These are the set of rules applied to columns on the table. It is used to bound the type of data that can go into a table.

Types of constraints
  • PRIMARY KEY
  • FOREIGN KEY
  • UNIQUE:
  • Not NULL
Q65. How can I see all indexes on a table in MySQL Database?
Answer

SHOW INDEX FROM TABLE_NAME;

Q66. How do I count the number of records in a MySQL query?
Answer

select count(*) from TABLE_NAME where 'status' = 1;

Q67. What is heap table in MySQL?
Answer

HEAP tables are in memory. No TEXT or BLOB fields are allowed inside HEAP tables. They are typically used for high-speed transient storage.

Q68. What is temporary table in MySQL?
Answer

In MySQL, a temporary table is a distinct type of table that approves you to save a transient end result set, in which you can reuse countless instances in a single session. A brief table is created with the aid of the use of the CREATE TEMPORARY TABLE statement.

Q69. How to upload a large file through phpmyadmin in MySQL?
Answer

It is the best way to upload large CSV files through the LOAD DATA command.

Syntax:

LOAD DATA LOCAL INFILE "your file name" INTO TABLE table name FIELDS TERMINATED by ’,’ LINES TERMINATED BY ’\n’

Q70. What is the degree of a table in MySQL?
Answer

The degree of a table is the number of columns in the given table. It is also called as Arity. It is the range of entities inside each entity type that can be linked via a given relationship type.

Conclusion

In MYSQL Database, data is stored in tabular form and that is why we also call it a Relational Database Management System. With the help of it, users can develop an infinite number of applications but it is mainly used for web applications. Talking about platforms, it can run on various platforms like LINUX, UNIX, and WINDOWS and is reliable, fast, and very easy to use. We hope these questions will help you to clear your core concepts regarding MYSQL. Let us help you with some short and important tips which might help you with your interviews-

  • MYSQL is a programming language, so always avoid YES and NO answers.
  • If you don’t know the answer, simply say I don't know rather than pretending you know.
  • Always carry a pen and notepad with you.
  • If you are stuck somewhere don’t panic, just stay calm and think out loud.
  • Go with the expectation that you will reject a lot, as “Failure is the key to Success”.
Reviewed and verified by Umesh Singh
Umesh Singh

My name is Umesh Singh having 11+ experience in Node.JS, React JS, Angular JS, Next JS, PHP, Laravel, WordPress, MySQL, Oracle, JavaScript, HTML and CSS etc. I have worked on around 30+ projects. I lo...