Interview Questions

Get ready for your next interview with our comprehensive question library

MySQL Interview Questions

Filter by Difficulty

1.

What is MySQL and what are its key features?

beginner

MySQL is an open-source relational database management system (RDBMS) that uses Structured Query Language (SQL). Key features include:

  • ACID Compliance: Ensures data integrity through Atomicity, Consistency, Isolation, and Durability
  • Cross-platform: Runs on various operating systems (Linux, Windows, macOS)
  • Storage Engines: Supports multiple storage engines like InnoDB, MyISAM, Memory
  • Replication: Master-slave and master-master replication support
  • Partitioning: Horizontal partitioning for large tables
  • Triggers and Stored Procedures: Server-side programming capabilities
  • Full-text Indexing: Advanced text search capabilities
  • High Performance: Optimized for speed and reliability
2.

What are the different storage engines in MySQL?

beginner

MySQL supports multiple storage engines, each optimized for different use cases:

  • InnoDB (Default): ACID-compliant, supports foreign keys, row-level locking, crash recovery
  • MyISAM: Table-level locking, faster for read-heavy workloads, no foreign key support
  • Memory/HEAP: Stores data in RAM, very fast but volatile
  • Archive: Compressed storage for archival data, insert and select only
  • CSV: Stores data in CSV format, useful for data exchange
  • Federated: Access remote MySQL tables as local tables
  • NDB: Clustered storage engine for MySQL Cluster

Example to check storage engine:

SHOW TABLE STATUS WHERE Name = 'table_name';
3.

Explain the difference between DELETE, DROP, and TRUNCATE.

beginner
  • DELETE: Removes specific rows based on WHERE clause, can be rolled back, triggers fire, slower
  • DROP: Removes entire table structure and data, cannot be rolled back, very fast
  • TRUNCATE: Removes all rows but keeps table structure, faster than DELETE, limited rollback
-- DELETE specific rows
DELETE FROM users WHERE age < 18;

-- TRUNCATE all data
TRUNCATE TABLE users;

-- DROP entire table
DROP TABLE users;
4.

What is the difference between CHAR and VARCHAR?

beginner
  • CHAR: Fixed-length string, padded with spaces, faster for fixed-size data, uses more storage
  • VARCHAR: Variable-length string, stores actual length + data, more storage efficient
-- CHAR always uses 10 bytes
name CHAR(10)

-- VARCHAR uses 1-255 bytes + length bytes
name VARCHAR(255)
5.

What are the numeric data types in MySQL?

beginner

MySQL numeric types include:

Integer Types:

  • TINYINT: 1 byte (-128 to 127)
  • SMALLINT: 2 bytes (-32,768 to 32,767)
  • MEDIUMINT: 3 bytes (-8,388,608 to 8,388,607)
  • INT: 4 bytes (-2,147,483,648 to 2,147,483,647)
  • BIGINT: 8 bytes (very large range)

Decimal Types:

  • DECIMAL/NUMERIC: Exact precision, for financial data
  • FLOAT: 4 bytes, approximate precision
  • DOUBLE: 8 bytes, double precision
CREATE TABLE products (
    id INT AUTO_INCREMENT PRIMARY KEY,
    price DECIMAL(10,2),
    weight FLOAT,
    quantity SMALLINT UNSIGNED
);
6.

Explain AUTO_INCREMENT in MySQL.

beginner

Upgrade to Premium to see the answer

Upgrade to Premium
7.

What are aggregate functions in MySQL?

beginner

Upgrade to Premium to see the answer

Upgrade to Premium
8.

Explain the LIMIT clause and its use with OFFSET.

beginner

Upgrade to Premium to see the answer

Upgrade to Premium
9.

What is database normalization and its forms?

intermediate

Upgrade to Premium to see the answer

Upgrade to Premium
10.

Explain the difference between HAVING and WHERE clauses.

intermediate

Upgrade to Premium to see the answer

Upgrade to Premium
11.

What is a subquery and what are its types?

intermediate

Upgrade to Premium to see the answer

Upgrade to Premium
12.

Explain different types of JOINs in MySQL.

intermediate

Upgrade to Premium to see the answer

Upgrade to Premium
13.

What is a self-join and when would you use it?

intermediate

Upgrade to Premium to see the answer

Upgrade to Premium
14.

Explain foreign key constraints.

intermediate

Upgrade to Premium to see the answer

Upgrade to Premium
15.

What is an index and why is it important?

intermediate

Upgrade to Premium to see the answer

Upgrade to Premium
16.

What are the different types of indexes in MySQL?

intermediate

Upgrade to Premium to see the answer

Upgrade to Premium
17.

Explain the EXPLAIN statement and its importance.

intermediate

Upgrade to Premium to see the answer

Upgrade to Premium
18.

What are stored procedures and their advantages?

intermediate

Upgrade to Premium to see the answer

Upgrade to Premium
19.

Explain triggers in MySQL.

intermediate

Upgrade to Premium to see the answer

Upgrade to Premium
20.

What are views and their benefits?

intermediate

Upgrade to Premium to see the answer

Upgrade to Premium
Showing 1 to 20 of 35 results

Premium Plan

$10.00 /monthly
  • Access all premium content - interview questions, and other learning resources

  • We regularly update our features and content, to ensure you get the most relevant and updated premium content.

  • 1000 monthly credits

  • Cancel anytime