
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
Can I use InnoDB and MyISAM tables in a single database in MySQL?
Yes, you can use InnoDB and MyISAM tables in one database or combine both of them in a single database. This is the recommended way.
Here is the demo of both MyISAM and InnoDB in a one database. The following is the database and both the table types InnoDB and MyISAM. The query to create a database is as follows −
mysql> create database BothInnoDBandMyISAM; Query OK, 1 row affected (0.20 sec) mysql> use BothInnoDBandMyISAM; Database changed
I have a database with name ‘BothInnoDBandMyISAM’.
First the table has engine type InnoDB. The query to create a table with engine InnoDB is as follows −
mysql> create table Student -> ( -> StudentId int, -> StudentName varchar(20) -> )ENGINE=InnoDB; Query OK, 0 rows affected (1.20 sec)
The second table has engine type MyISAM. The query to create a table with engine MyISAM is as follows −
mysql> create table Employee -> ( -> EmployeeId int, -> EmployeeName varchar(30) -> )ENGINE=MyISAM; Query OK, 0 rows affected (0.28 sec)
Here is the query to check the engine type from the same database. The query is as follows for the first table.
mysql> select engine from information_schema.tables where table_name='Student' and table_schema='BothInnoDBandMyISAM';
The following is the output −
+--------+ | ENGINE | +--------+ | InnoDB | +--------+ 1 row in set (0.00 sec)
Here is the query to check table engine type from the same database. The query is as follows for the second table.
mysql> select engine from information_schema.tables where table_name='Employee' and table_schema='BothInnoDBandMyISAM';
The following is the output −
+--------+ | ENGINE | +--------+ | MyISAM | +--------+ 1 row in set (0.00 sec)
- Related Articles
- MyISAM versus InnoDB in MySQL?
- How can I set a MySQL database to use MyISAM by default?
- When to use MyISAM and InnoDB?
- How can I describe all tables in the database through a single statement in MySQL?
- Converting table from MyISAM to INNODB in MySQL?
- How to convert MyISAM to InnoDB storage engine in MySQL?
- MySQL - changing table engine from innoDB to MyISAM?
- How do I know if a MySQL table is using myISAM or InnoDB Engine?
- How Can I check the size of the tables in a particular MySQL database?
- How can I see global locks in MySQL (innodb)?
- How can I install or enable innoDB in MySQL?
- How can I display all databases in MySQL and for each database show all tables?
- How can I check MySQL tables from a database in accordance with particular\ncolumn/s name?
- Given a column name how can I find which tables in a MySQL database contain that column?
- How can I get the output of multiple MySQL tables from a single query?
