zoukankan      html  css  js  c++  java
  • 学习计划 mysql 引擎

    --

    什么是引擎?

      按照我现在的勒戒,就可以提供 Mysql 对不同表的处理方式,各有优缺点。

      就像名字一样,把我们数据库看成法拉利的话,引擎也就是发送机,有的跑的快,有的距离长.......

    --

    有什么样的引擎可以供我们选择?

      使用 show engines 命令,在 Mysql 下输出可供选择的引擎。

    mysql> show engines;
    +--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
    | Engine             | Support | Comment                                                        | Transactions | XA   | Savepoints |
    +--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
    | MyISAM             | YES     | MyISAM storage engine                                          | NO           | NO   | NO         |
    | MRG_MYISAM         | YES     | Collection of identical MyISAM tables                          | NO           | NO   | NO         |
    | CSV                | YES     | CSV storage engine                                             | NO           | NO   | NO         |
    | BLACKHOLE          | YES     | /dev/null storage engine (anything you write to it disappears) | NO           | NO   | NO         |
    | PERFORMANCE_SCHEMA | YES     | Performance Schema                                             | NO           | NO   | NO         |
    | InnoDB             | DEFAULT | Supports transactions, row-level locking, and foreign keys     | YES          | YES  | YES        |
    | ARCHIVE            | YES     | Archive storage engine                                         | NO           | NO   | NO         |
    | MEMORY             | YES     | Hash based, stored in memory, useful for temporary tables      | NO           | NO   | NO         |
    | FEDERATED          | NO      | Federated MySQL storage engine                                 | NULL         | NULL | NULL       |
    +--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
    9 rows in set (0.00 sec)
    

    这里定义了所有引擎和支持的特性。

    --

    这么多引擎,我们在使用中应该使用使用什么样子的引擎?

    这里就要看一下这些引擎的优点和适用的方向了。

    除非需要用到某些InnoDB 不具备的特性,并且没有其他办法可以替代,否则都应该选择INNODB 引擎

    这里的文章很详细的讲解了为什么要选择InnoDB

      https://www.2cto.com/database/201511/450392.html

    --

    那如何查看我们现在使用什么引擎的呢?

      1:查看创建表SQL

    mysql> show create table 表名;
    

    这里定义了我们的数据库引擎。

    --

    但是,如果我们在创建表时并没有指定引擎,那我们的这张表的引擎是什么呢?

    像这样
    mysql> create table h(`id` int);
    

    但是

    设置了engine,因为Mysql有默认的引擎,在你没有定义你的引擎时候。

    查看默认引擎
    mysql> show variables like '%storage_engine%';
    +----------------------------------+--------+
    | Variable_name                    | Value  |
    +----------------------------------+--------+
    | default_storage_engine           | InnoDB |
    | default_tmp_storage_engine       | InnoDB |
    | disabled_storage_engines         |        |
    | internal_tmp_disk_storage_engine | InnoDB |
    +----------------------------------+--------+
    4 rows in set (0.00 sec)
    

    这个 default_storage_engine 就是默认的引擎。

    --

    那么我们怎么修改默认引擎/表引擎?

     修改表引擎

    mysql> alter table 表名 engine=引擎;
    

     修改默认引擎

    设置InnoDB为默认引擎:
    在配置文件my.ini中的 [mysqld] 下面加入default-storage-engine=INNODB
    

    --

    PS

      在一个库中可以有多个表,多个引擎。

    --

    今天的学习知识对数据库引擎有了一个大致了解,之后更具体的还是应该通过具体学习来实现。

  • 相关阅读:
    ActiveMQ 即时通讯服务 浅析
    Asp.net Mvc (Filter及其执行顺序)
    ActiveMQ基本介绍
    ActiveMQ持久化消息的三种方式
    Windows Azure Virtual Machine (27) 使用psping工具,测试Azure VM网络连通性
    Azure China (10) 使用Azure China SAS Token
    Windows Azure Affinity Groups (3) 修改虚拟网络地缘组(Affinity Group)的配置
    Windows Azure Storage (22) Azure Storage如何支持多级目录
    Windows Azure Virtual Machine (26) 使用高级存储(SSD)和DS系列VM
    Azure Redis Cache (2) 创建和使用Azure Redis Cache
  • 原文地址:https://www.cnblogs.com/25-lH/p/8664531.html
Copyright © 2011-2022 走看看