All MySQL Interview Questions
A storage engine (database engines) is a software component that handles SQL Operations (create, read, update data) for various tables. The default storage engine for MySQL prior to version 5.5 was MyISAM.
MySQL 5.6 Supported Storage Engines
It is essential to understand the features of each table type in MySQL so that you can use them effectively to maximize the performance of your databases.
InnoDB: The default storage engine in MySQL 5.6. InnoDB is a transaction-safe (ACID compliant) storage engine for MySQL that has commit, rollback, and crash-recovery capabilities to protect user data. InnoDB row-level locking and Oracle-style consistent nonlocking reads increase multi-user concurrency and performance. InnoDB stores user data in clustered indexes to reduce I/O for common queries based on primary keys. To maintain data integrity, InnoDB also supports FOREIGN KEY referential-integrity constraints.
MyISAM: Table-level locking limits the performance in read/write workloads, so it is often used in read-only or read-mostly workloads in Web and data warehousing configurations. Before MySQL version 5.5, MyISAM is the default storage engine when you create a table without specifying the storage engine explicitly. The MyISAM tables are not transaction-safe.
Memory: Stores all data in RAM, for fast access in environments that require quick lookups of non-critical data. This engine was formerly known as the HEAP engine. Its use cases are decreasing; InnoDB with its buffer pool memory area provides a general-purpose and durable way to keep most or all data in memory, and NDBCLUSTER provides fast key-value lookups for huge distributed data sets.
CSV: Its tables are really text files with comma-separated values. CSV tables let you import or dump data in CSV format, to exchange data with scripts and applications that read and write that same format. Because CSV tables are not indexed, you typically keep the data in InnoDB tables during normal operation, and only use CSV tables during the import or export stage.
Archive: These compact, unindexed tables are intended for storing and retrieving large amounts of seldom-referenced historical, archived, or security audit information.
Blackhole: The Blackhole storage engine accepts but does not store data, similar to the Unix /dev/null device. Queries always return an empty set. These tables can be used in replication configurations where DML statements are sent to slave servers, but the master server does not keep its own copy of the data.
NDB (also known as NDBCLUSTER)—This clustered database engine is particularly suited for applications that require the highest possible degree of uptime and availability.
The NDB storage engine is not supported in standard MySQL 5.6 releases. Currently supported MySQL Cluster releases include MySQL Cluster NDB 7.1, which is based on MySQL 5.1; MySQL Cluster NDB 7.4, currently in development and also based on MySQL 5.6, is now also available in a Developer Milestone release.
Merge: Enables a MySQL DBA or developer to logically group a series of identical MyISAM tables and reference them as one object. Good for VLDB environments such as data warehousing.
Federated: Offers the ability to link separate MySQL servers to create one logical database from many physical servers. Very good for distributed or data mart environments.
Example: This engine serves as an example in the MySQL source code that illustrates how to begin writing new storage engines. It is primarily of interest to developers.
You are not restricted to using the same storage engine for an entire server or schema. You can specify the storage engine for any table. For example, an application might use mostly InnoDB tables, with one CSV table for exporting data to a spreadsheet and a few MEMORY tables for temporary workspaces.
You can use “LIMIT” to restrict a number of records and “ORDER BY” to sort according to the specific column name.
select * from students ORDER BY student_id LIMIT 10;
Table name is “student” and You need to select all students whom marks are less than 50%.
You need to put condition in “WHERE” clause
SELECT * FROM student WHERE marks < 50
Table name is “student” and You need to select all students where marks are between 70 and 80%.
MySQL BETWEEN Operator is used to specify range of values in condition.
SELECT * FROM student WHERE marks BETWEEN 70 and 80