MySQL - required interview questions ①

1. Why use a database

① Data is stored in memory

Pros: fast access

Cons: Data cannot be stored permanently

② Save the data in the file

Advantages: Data is permanently stored

shortcoming:

  1. Slower than memory operations, frequent IO operations
  2. Inconvenient to query data

③ Data is saved in the database

  1. data permanent storage
  2. Using SQL statements, the query is convenient and efficient
  3. Easy to manage data

2. What is SQL?

Structured Query Language (Structured Query Language) referred to as SQL, is a database query language.

Role: used to access data, query, update and manage relational database systems.

3. What is MySQL?

MySQL is a relational database management system, developed by the Swedish company MySQL AB, which is a product of Oracle. MySQL is one of the popular relational database management systems. In terms of WEB applications, MySQL is one of the best RDBMS (Relational Database Management System) application software. It is commonly used in Java enterprise-level development, because MySQL is open source, free, and easy to expand.

4. What are the three major database paradigms?

First Normal Form: Each column cannot be split again.

Second normal form: On the basis of the first normal form, non-primary key columns are completely dependent on the primary key, but cannot be part of the primary key.

The third normal form: On the basis of the second normal form, non-primary key columns only depend on the primary key and do not depend on other non-primary keys.

When designing the database structure, try to comply with the three paradigms. If you do not comply, there must be sufficient reasons. Such as performance. In fact we often compromise database design for performance.

5. What are the tables related to permissions in mysql?

The MySQL server controls user access to the database through the permission table, which is stored in the mysql database and initialized by the mysql_install_db script. These permission tables are user, db, table_priv, columns_priv and host respectively.

The structure and contents of these tables are introduced respectively below.

  1. User permission table: records the user account information that is allowed to connect to the server, and the permissions in it are at the global level.
  2. db authority table: records the operation authority of each account on each database.
  3. table_priv permission table: records the operation permissions at the data table level.
  4. columns_priv permission table: records data column-level operation permissions.
  5. Host permission table: cooperate with the db permission table to control the database-level operation permissions on a given host in more detail.

 This privilege table is not affected by GRANT and REVOKE statements.

6. How many input formats does MySQL's binlog have? What's the difference?

There are three formats: [statement, row, mixed]

In statement mode: every sql that will modify data will be recorded in binlog. There is no need to record the changes of each row, which reduces the amount of binlog logs, saves IO, and improves performance. Since the execution of sql has a context, relevant information needs to be saved when saving, and some statements that use functions cannot be recorded and copied.

At the row level: the context-related information of the SQL statement is not recorded, and only which record is modified is saved. The recording unit is the change of each row, which can basically be recorded. However, due to many operations, a large number of rows will be changed (such as alter table), so this mode of file saves too much information and the amount of logs is too large.

mixed : A compromise solution. Common operations use statement records, and rows are used when statements cannot be used.

In addition, some optimizations have been made to the row level in the new version of MySQL. When the table structure changes, the statement will be recorded instead of row-by-row.

Guess you like

Origin blog.csdn.net/qq_53142796/article/details/132565053