zoukankan      html  css  js  c++  java
  • mysql 存储引擎 memory

    查看支持的引擎

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

    Memory表被存储在内存中。且默认使用哈希索引。这使得它们很快,而且对创建暂时表很实用。但是。当server关闭之时,全部存储在Memory表里的数据被丢失。

    由于表的定义被存在磁盘上的.frm文件里,所以表自身继续存在。在server重新启动动时它们是空的。

    要明白指出你想要一个Memory表。可使用ENGINE选项来指定:

    CREATE TABLE t (i INT) ENGINE = MEMORY;
    
    CREATE TABLE test ENGINE=MEMORY;
    SELECT ip,SUM(downloads) AS down FROM log_table GROUP BY ip;
    SELECT COUNT(ip),AVG(down) FROM test;
    DROP TABLE test;
    
  • 相关阅读:
    基于typora编写Markdown文档
    VMware Workstation常见的故障处理
    VMware Workstation产品常用的快捷键
    2
    1
    9
    8
    7
    6
    5
  • 原文地址:https://www.cnblogs.com/brady-wang/p/15116260.html
Copyright © 2011-2022 走看看