zoukankan      html  css  js  c++  java
  • MySQL 如何查看表的存储引擎

    MySQL 如何查看表的存储引擎

     

    在MySQL中如何查看单个表的存储引擎? 如何查看整个数据库有那些表是某个特殊存储引擎,例如MyISAM存储引擎呢?下面简单的整理一下这方面的知识点。

     

    如果要查看单个表的存储引擎,可以用show create table命令查看该表的存储引擎,那么有下面一些方法:

     

    方法1:

     

    mysql> show create table test;                 
    +-------+----------------------------------------------+
    | Table | Create Table                                 |
    +-------+----------------------------------------------+
    | test  | CREATE TABLE `test` (
      `id` int(11) DEFAULT NULL,
      `name` varchar(12) DEFAULT NULL
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
    +-------+----------------------------------------------+
    1 row in set (0.00 sec)
     
    mysql> 

     

     

    clip_image001

     

     

     

    方法2:

     

    mysql> show table status from MyDB where name='test' G
    *************************** 1. row ***************************
               Name: test
             Engine: InnoDB
            Version: 10
         Row_format: Compact
               Rows: 0
     Avg_row_length: 0
        Data_length: 16384
    Max_data_length: 0
       Index_length: 0
          Data_free: 0
     Auto_increment: NULL
        Create_time: 2017-06-09 15:45:00
        Update_time: NULL
         Check_time: NULL
          Collation: utf8_general_ci
           Checksum: NULL
     Create_options: 
            Comment: 
    1 row in set (0.01 sec)

     

     

    clip_image002

     

     

    方法3:

     

     

    mysql> 
    mysql> select table_catalog
        ->       ,table_schema
        ->       ,table_name
        ->       ,engine
        -> from tables
        -> where table_schema='MyDB' and table_name='test';
    +---------------+--------------+------------+--------+
    | table_catalog | table_schema | table_name | engine |
    +---------------+--------------+------------+--------+
    | def           | MyDB         | test       | InnoDB |
    +---------------+--------------+------------+--------+
    1 row in set (0.00 sec)
     
    mysql> 

     

    clip_image003

     

     

    如果要查询某个库或所有实例里面表使用的存储引擎,那么可以使用information_schema.tables来查询。下面是简单的几个例子。

     

     

    查询整个MySQL实例里面存储引擎为MyISAM的表

     

    select table_catalog
          ,table_schema
          ,table_name
          ,engine
    from information_schema.tables
    where engine='MyISAM';

     

    查询MyDB数据库里面存储引擎为MyISAM的表

     

    select table_catalog
          ,table_schema
          ,table_name
          ,engine
    from information_schema.tables
    where table_schema='MyDB' and engine='MyISAM';
  • 相关阅读:
    数据报表开发技巧:自动为数据报表添加【小计】、【总计】行
    使用Xamarin开发手机聊天程序 -- 基础篇(大量图文讲解 step by step,附源码下载)
    如何让服务端同时支持WebSocket和SSL加密的WebSocket(即同时支持ws和wss)?
    Unity3D 预备知识:C#与Lua相互调用
    进程守护系统,你懂吗?
    Xamarin 跨移动端开发系列(01) -- 搭建环境、编译、调试、部署、运行
    程序员与禅的对话录
    技术人的慰藉
    我的作品
    自动升级系统的设计与实现(续2) -- 增加断点续传功能 (附最新源码)
  • 原文地址:https://www.cnblogs.com/kerrycode/p/6999550.html
Copyright © 2011-2022 走看看