Preface:In interviews for various technical positions, it seems that MySQL-related questions are often asked. Whether you are interviewing for a development position or an operations position, you will always be asked a few database questions. Friends often send me private messages asking how to deal with MySQL interview questions. In fact, many interview questions are similar, so it is necessary to prepare in advance. This article briefly talks about several common interview questions. Let’s learn together. 1. What is a relational database? Talk about your understanding of MySQL.This is a basic question that tests the interviewee's understanding of databases. Generally, you can briefly talk about your understanding in an organized manner. for example: A relational database is a database that uses a relational model to organize data and stores data in the form of rows and columns. The biggest feature of relational databases is that they support transactions. Common relational databases include MySQL, Oracle, SQLServer, etc. MySQL is the most popular open source database. Due to its small size, fast speed, low total cost of ownership, and especially its open source nature, many companies have adopted the MySQL database to reduce costs. It is currently widely used in small and medium-sized websites on the Internet, especially in the OLTP field. 2.What are the common storage engines for MySQL and what are their differences?This question is also often asked, and is similar to the question "What is the difference between InnoDB and MyISAM engines?" Several common storage engines:
Several differences between InnoDB and MyISAM engines:
3. Describe the MySQL infrastructure.This question tests the interviewee's understanding of MySQL architecture and is similar to the question "Execution flow of a select statement". The logical architecture of MySQL is mainly divided into three layers:
The execution flow of a select statement:
4. Talk about several commonly used field types.This question tests the interviewee's understanding of MySQL field types and can lead to many small questions, such as the difference between char and varchar. Commonly used field type classification: Numeric type: String type: Date and time types: The M in int(M) stands for the maximum display width. Our first reaction to "maximum display width" is the maximum width of the value that the field can store. We might think that since we created int(1), we cannot store the data 10. In fact, this is not the case. int(5) and int(10) have the same storage range. The CHAR type is fixed-length, and MySQL always allocates enough space based on the defined string length. When CHAR values are stored, they are padded on the right with spaces to the specified length, and when CHAR values are retrieved, trailing spaces are removed. The VARCHAR type is used to store variable-length strings. When storing, if the number of characters does not reach the defined number of digits, no spaces will be added at the end. The M in char(M) and varchar(M) represents the maximum number of characters that can be stored. A single letter, number, Chinese character, etc. takes up one character. 5. Talk about the role, structure and usage specifications of indexes.There are so many questions about indexing that it may take more than a few articles to explain them clearly. Simply share the answers to these questions: The purpose of indexing is to improve query efficiency. It can be compared to the directory in a dictionary. When searching for dictionary content, you can find the storage location of the data based on the directory and then obtain it directly. An index is a table directory. Before searching for content, you can first search for the index location in the directory to quickly locate the query data. Under the InnoDB engine, the B+Tree index is mainly used. Each index is actually a B+ tree. The B+ tree is a balanced search tree (not a binary tree) designed for disks and other storage auxiliary devices. In the B+ tree, all data is in the leaf nodes, and each leaf node has a pointer to the next node, forming an ordered linked list. From a physical storage perspective, InnoDB indexes can be divided into clustered indexes and secondary indexes or auxiliary indexes. The leaf nodes of the clustered index store the entire row of data. When a query uses the clustered index, you only need to scan a B+ tree of the clustered index to get the required records. If you want to find the complete record through the secondary index, you need to go back to the table, that is, find the primary key value through the secondary index and then find the complete record in the clustered index. The obvious advantage of indexes is that they can speed up queries, but creating indexes also comes at a cost. First, each time an index is created, a B+ tree must be created for it, which will take up additional storage space; secondly, when the data in the table is added, deleted, or modified, the index also needs to be dynamically maintained, which reduces the speed of data maintenance. Therefore, there are principles for creating and using indexes. Generally, indexes are only created for columns used for searching, sorting, grouping, and joining. Indexes should not be created for columns with poor selectivity as much as possible. 6. Talk about the characteristics and isolation levels of MySQL transactions.Questions related to MySQL transactions are also often asked, and some principles still need to be studied in depth. ACID has four characteristics:
Transaction isolation level:
Problems caused by concurrent transactions:
The above are the detailed answers to several high-frequency MySQL interview questions. For more information about high-frequency MySQL interview questions, please pay attention to other related articles on 123WORDPRESS.COM! You may also be interested in:
|
<<: Summary of 7 reasons why Docker is not suitable for deploying databases
>>: Use CSS and Bootstrap icons to create an up and down jumping indicator arrow animation effect
This article shares with you how to use the Vue s...
Table of contents 1. Baidu Map API Access 2. Usin...
Question 1: How do you instruct the browser to dis...
Table of contents Parsers and preprocessors Query...
1. View the renderings Select forward: Select bac...
1. Unzip mysql-8.0.21-winx64 2. Configure environ...
The installation of MySQL 5.7 on Ubuntu 1804 is i...
The EXPLAIN statement provides information about ...
Use MySQL proxies_priv (simulated role) to implem...
<div class="sideBar"> <div>...
Using CSS layout to create web pages that comply w...
Table of contents Preface vue.config.js configura...
This article shares the specific code for impleme...
Check if MySQL is already installed in Linux sudo...
The reason is that it was not uninstalled cleanly...