zoukankan      html  css  js  c++  java
  • 【MySQL】修改表的存储引擎

    查看表的存储引擎用命令 show create table 表名

    更改表的存储引擎用命令 alter table 表名 set ENGINE=新引擎名

    示例如下:

    mysql> show create table t01;
    +-------+------------------------------------------------------------------------------------------------------------------------------------------+
    | Table | Create Table                                                                                                                             |
    +-------+------------------------------------------------------------------------------------------------------------------------------------------+
    | t01   | CREATE TABLE `t01` (
      `id` int(11) NOT NULL,
      `name` varchar(22) NOT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
    +-------+------------------------------------------------------------------------------------------------------------------------------------------+
    1 row in set (0.05 sec)
    
    mysql> alter table t01 engine=MyISAM;
    Query OK, 0 rows affected (0.23 sec)
    Records: 0  Duplicates: 0  Warnings: 0
    
    mysql> show create table t01;
    +-------+------------------------------------------------------------------------------------------------------------------------------------------+
    | Table | Create Table                                                                                                                             |
    +-------+------------------------------------------------------------------------------------------------------------------------------------------+
    | t01   | CREATE TABLE `t01` (
      `id` int(11) NOT NULL,
      `name` varchar(22) NOT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
    +-------+------------------------------------------------------------------------------------------------------------------------------------------+
    1 row in set (0.00 sec)
    
    mysql>

    玩完后记得改回原样哦。

    mysql> alter table t01 ENGINE=INNODB;
    Query OK, 0 rows affected (0.14 sec)
    Records: 0  Duplicates: 0  Warnings: 0
    
    mysql> show create table t01;
    +-------+------------------------------------------------------------------------------------------------------------------------------------------+
    | Table | Create Table                                                                                                                             |
    +-------+------------------------------------------------------------------------------------------------------------------------------------------+
    | t01   | CREATE TABLE `t01` (
      `id` int(11) NOT NULL,
      `name` varchar(22) NOT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
    +-------+------------------------------------------------------------------------------------------------------------------------------------------+
    1 row in set (0.00 sec)

    --END--

  • 相关阅读:
    CDH5.2安装更换hive元数据存储数据库遇到的问题
    SSH 互信
    【记录】Java NIO实现网络模块遇到的BUG
    Http2协议简介
    synchronized(this) 与 synchronized(class) 理解
    【记录】spring boot 图片上传与显示
    Cookie-Session机制
    linux利用用户组给用户赋予不同的权限
    java .equals()和==的区别
    String直接赋值和使用new的区别
  • 原文地址:https://www.cnblogs.com/heyang78/p/15120365.html
Copyright © 2011-2022 走看看