Home  >  Article  >  Database  >  COMMON MYSQL INTERVIEW QUESTIONS

COMMON MYSQL INTERVIEW QUESTIONS

Linda Hamilton
Linda HamiltonOriginal
2024-10-18 14:07:30924browse

COMMON MYSQL INTERVIEW QUESTIONS

A. 初心者レベルの MySQL の質問:

  1. MySQL とは何ですか?

    • MySQL は、データベースに格納されているデータへのアクセス、管理、操作に構造化照会言語 (SQL) を使用するオープンソースのリレーショナル データベース管理システム (RDBMS) です。
  2. MySQL の主な機能は何ですか?

    • オープンソース、クロスプラットフォームのサポート、高性能、複雑なクエリのサポート、セキュリティ機能、ACID 準拠、スケーラビリティ、レプリケーション、クラスタリング。
  3. リレーショナル データベースとは何ですか?

    • リレーショナル データベースは、行と列で構成されるテーブルにデータを格納するデータベースの一種です。各テーブルには一意のキーがあり、テーブル間の関係は外部キーを使用して確立されます。
  4. SQL とは何ですか?

    • SQL (Structured Query Language) は、データのクエリ、挿入、更新、削除などのタスクを含む、リレーショナル データベースの管理と操作に使用される標準プログラミング言語です。
  5. MySQL のさまざまなデータ型とは何ですか?

    • MySQL は次のようなさまざまなデータ型をサポートしています。
      • 数値: INT、FLOAT、DOUBLE、DECIMAL
      • 文字列: VARCHAR、TEXT、CHAR
      • 日付と時刻: 日付、日時、タイムスタンプ、時刻
      • バイナリ: BLOB、BINARY
  6. 主キーとは何ですか?

    • 主キーは、テーブル レコードの一意の識別子です。これにより、主キー列に重複した値が格納されなくなり、各テーブルに主キーを 1 つだけ持つことができます。
  7. 外部キーとは何ですか?

    • 外部キーは、別のテーブルの行を一意に識別するテーブル内のフィールド (またはフィールドのコレクション) で、2 つのテーブル間のリンクを確立し、参照整合性を強制します。
  8. CHAR と VARCHAR の違いは何ですか?

    • CHAR は固定長文字列ですが、VARCHAR は可変長文字列です。 CHAR は文字列の長さが予測可能な場合に使用されますが、VARCHAR はさまざまな長さに対してスペース効率が高くなります。
  9. MySQL の AUTO_INCREMENT とは何ですか?

    • AUTO_INCREMENT は、テーブル内の新しいレコードの一意の識別子を自動的に生成する MySQL の機能で、主キー列によく使用されます。
  10. SQL の JOIN 句とは何ですか?

    • JOIN は、関連する列に基づいて 2 つ以上のテーブルの行を結合するために使用されます。タイプには、INNER JOIN、LEFT JOIN、RIGHT JOIN、FULL JOIN があります。
  11. INNER JOIN とは何ですか?

    • INNER JOIN は、結合される両方のテーブルで一致する値を持つ行のみを返します。
  12. 左結合とは何ですか?

    • LEFT JOIN は、左側のテーブルからすべての行を返し、右側のテーブルから一致した行を返します。一致するものが見つからない場合は、右側のテーブルの列に対して NULL 値が返されます。
  13. SQL の UNION とは何ですか?

    • UNION は、2 つ以上の SELECT クエリの結果セットを結合し、クエリ間の重複行を削除します。すべての SELECT ステートメントの列は、同じ番号とデータ型を持つ必要があります。
  14. UNION と UNION ALL の違いは何ですか?

    • UNION は重複した行を削除しますが、UNION ALL は結合された結果セットからすべての重複を含みます。
  15. GROUP BY 句とは何ですか?

    • GROUP BY は、同じ値を持つ行を集計行にグループ化し、SUM()、AVG()、COUNT()、MIN()、MAX() などの集計関数でよく使用されます。

B. 中級レベルの MySQL の質問:

  1. MySQL のインデックスとは何ですか?

    • インデックスは、テーブルのデータ取得操作の速度を向上させるデータ構造です。テーブル全体をスキャンせずにデータをすばやく見つけるために使用されます。
  2. MySQL のインデックスにはどのような種類がありますか?

    • MySQL の一般的なインデックス タイプには次のものがあります。
      • 主インデックス: 主キーに対して自動的に作成されます。
      • 一意のインデックス: インデックス付き列内のすべての値が一意であることを保証します。
      • 全文インデックス: テキスト検索に使用されます。
      • 複合インデックス: 複数の列のインデックス。
  3. 正規化とは何ですか?

    • Normalization is the process of organizing database tables to reduce redundancy and improve data integrity. It involves dividing large tables into smaller, related tables.
  4. What is denormalization?

    • Denormalization is the process of combining tables to reduce the number of joins and improve query performance, often used in read-heavy applications.
  5. What is the HAVING clause?

    • HAVING is used to filter records after an aggregation is applied, typically with GROUP BY. It is similar to WHERE, but WHERE is applied before aggregation.
  6. What is a stored procedure?

    • A stored procedure is a set of SQL statements that can be executed as a single unit. It is stored in the database and can be called with a specific name, often used to encapsulate complex logic.
  7. What is a trigger in MySQL?

    • A trigger is a set of SQL statements that automatically executes when a specified event (INSERT, UPDATE, DELETE) occurs on a table.
  8. What is a view in MySQL?

    • A view is a virtual table that is based on the result of a SELECT query. It does not store data physically but provides a way to simplify complex queries.
  9. What is a transaction in MySQL?

    • A transaction is a sequence of SQL statements that are executed as a single unit of work. It follows ACID properties (Atomicity, Consistency, Isolation, Durability).
  10. What are ACID properties?

    • Atomicity: All operations within a transaction are completed or none are.
    • Consistency: Transactions bring the database from one valid state to another.
    • Isolation: Transactions do not interfere with each other.
    • Durability: Once a transaction is committed, changes are permanent.

C. Advanced-Level MySQL Questions:

  1. What is replication in MySQL?

    • Replication is the process of copying data from one MySQL server (master) to one or more servers (slaves) for redundancy and load balancing.
  2. What are the different types of replication in MySQL?

    • Master-Slave Replication: Data is written to the master and replicated to slaves.
    • Master-Master Replication: Both servers can act as master and replicate data to each other.
    • Group Replication: Multi-master replication for highly available MySQL clusters.
  3. What is the InnoDB storage engine?

    • InnoDB is the default storage engine in MySQL, providing support for ACID-compliant transactions, foreign keys, and crash recovery.
  4. What is the difference between DELETE, TRUNCATE, and DROP?

    • DELETE: Removes rows from a table based on a condition. It can be rolled back.
    • TRUNCATE: Removes all rows from a table but retains its structure. It cannot be rolled back.
    • DROP: Deletes the entire table, including its structure. It cannot be rolled back.
  5. How do you optimize a slow query in MySQL?

    • Techniques include using proper indexing, analyzing query execution plans (EXPLAIN), rewriting queries for efficiency, using JOIN instead of subqueries, avoiding SELECT *, and ensuring hardware resources are adequate.

The above is the detailed content of COMMON MYSQL INTERVIEW QUESTIONS. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn