zoukankan      html  css  js  c++  java
  • mysql存储引擎管理使用

    mysql采用插件化架构,可以支持不同的存储引擎,比如myisam,innodb。本文简单的介绍mysql存储引擎的管理与使用。

    1、查看mysql存储引擎:show engines;

    可以看到,mysql 5.7支持InnoDB,MRG_MYISAM,CSV,MyISAM等8种存储引擎,其中InnoDB位默认存储引擎,支持事务,行级锁,外键。

    2、查看city创表语句:show create table city;

    可以看到,city表使用Innodb存储引擎。

    3、 查询所有表的存储引擎使用情况:show table status;

    可以看到,wold库下所有表都是InnoDB引擎。

    4、创表指定存储引擎:create table test(id int default null) engine = myisam;

    5、修改表的存储引擎:alter table test engine=innodb;

    6、修改默认存储引擎

    # The default storage engine that will be used when create new tables when
    default-storage-engine=INNODB
    
    # When innodb_file_per_table is enabled (the default in 5.6.6 and higher), InnoDB stores the data and indexes for each newly created table
    # in a separate .ibd file, rather than in the system tablespace.
    innodb_file_per_table=1

    修改配置文件后重启mysql。innodb_file_per_table=1表示每个表采用不同文件存储数据和索引,0表示所有表共享一份数据文件(系统表空间)。

    7、innodb和myisam存储引擎数据文件

    (1)innodb数据文件

    每个表包含2份数据文件,.frm是表结构描述文件,.ibd是表索引与表数据文件。(前面文章中已经介绍过innodb表索引和数据都存在B+Tree中)

    下图中ibdata1是系统表空间,innodb_file_per_table=0时,所有innodb表数据与索引都存在此文件中。

    (2)myisam数据文件

    库coshaho001下面全部是myisam表,每个表包含3个数据文件,.frm是表结构描述文件,.MYD是数据文件,.MYI是索引文件。(前面文章中已经介绍过myisam表索引和数据分开存储)

  • 相关阅读:
    【Luogu】P1419寻找段落(单调队列)
    【Luogu】P1411树(树形高精DP)
    【Luogu】P2886牛继电器(矩阵加速floyd)
    【Luogu】P2657windy数(数位DP)
    【Luogu】P3521ROT-Tree Rotations(线段树合并)
    24-Perl 数据库连接
    23-Perl 面向对象
    22-Perl Socket 编程
    21-Perl 发送邮件
    20-Perl 正则表达式
  • 原文地址:https://www.cnblogs.com/coshaho/p/7208683.html
Copyright © 2011-2022 走看看