ITPub博客

首页 > 数据库 > MySQL > CSV ,ARCHIVE 存储引擎 介绍

CSV ,ARCHIVE 存储引擎 介绍

原创 MySQL 作者:huzhichengforce 时间:2015-02-28 12:40:18 0 删除 编辑
创建CSV 引擎表语法
create table table_name (column_name type not null,column_name type not null,column_name type not null) engine=CSV;
CSV 引擎表所有的字段都必须为非空
创建的CSV 引擎表有两个文件一个以CSV 结尾,一个以CSM 结尾。

archive 引擎 适用于历史数据归档,使用zip 压缩算法节省空间效果显著 不足之处在于只支持insert select 操作。 能支持order by BLOB 不支持索引,插入效率极高数据使用空间小,使用archive 引擎会产生一个.frm 标准文件还有一个扩展名为.arz 的文件。 优化操作时可能存在一个.arn 的文件.
下列使用archive 引擎,innodb,myisam 各创建一张表看效果
原有一张表user已有数据13W
>show table status like 'user'\G
mysql> show table status like 'user'\G
*************************** 1. row ***************************
           Name: user
         Engine: InnoDB
        Version: 10
     Row_format: Compact
           Rows: 130680
 Avg_row_length: 68
    Data_length: 8929280
Max_data_length: 0
   Index_length: 0
      Data_free: 4194304
 Auto_increment: NULL
    Create_time: 2015-02-02 04:30:20
    Update_time: NULL
     Check_time: NULL
      Collation: latin1_swedish_ci
       Checksum: NULL
 Create_options:
        Comment:
1 row in set (0.00 sec)
创建myisam引擎表
created table u1 engine=myisam as select * from user;
mysql> show table status like 'u1'\G
*************************** 1. row ***************************
           Name: u1
         Engine: MyISAM
        Version: 10
     Row_format: Dynamic
           Rows: 131072
 Avg_row_length: 55
    Data_length: 7340024
Max_data_length: 281474976710655
   Index_length: 1024
      Data_free: 0
 Auto_increment: NULL
    Create_time: 2015-02-05 06:38:12
    Update_time: 2015-02-05 06:38:12
     Check_time: NULL
      Collation: utf8_general_ci
       Checksum: NULL
 Create_options:
        Comment:
1 row in set (0.00 sec)
创建archive引擎表
created table u1 engine=archive as select * from user;
mysql> show table status like 'u2'\G
*************************** 1. row ***************************
           Name: u2
         Engine: ARCHIVE
        Version: 10
     Row_format: Compressed
           Rows: 131072
 Avg_row_length: 2
    Data_length: 348329
Max_data_length: 0
   Index_length: 0
      Data_free: 0
 Auto_increment: NULL
    Create_time: NULL
    Update_time: 2015-02-05 06:39:08
     Check_time: NULL
      Collation: utf8_general_ci
       Checksum: NULL
 Create_options:
        Comment:
1 row in set (0.05 sec)
Rows 不准!!!!!!!!!! !!!!!
对于不同的引擎准确度不同!!!

为什么mysql用SHOW TABLE STATUS 查看表的记录数和负责终端查看到的记录数不一样?


与你使用的表引擎有关系。
官方文档的说明:
The number of rows. Some storage engines, such as MyISAM, store the exact count. For other storage engines, such as InnoDB, this value is an approximation, and may vary from the actual value by as much as 40 to 50%. In such cases, use SELECT COUNT(*) to obtain an accurate count.
在myisam这种不支持事务的引擎中,这个值是精确的,在innodb这种支持事务的引擎中,是估算的。

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/26764973/viewspace-1443615/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: MERGE 存储引擎
请登录后发表评论 登录
全部评论

注册时间:2012-08-19

  • 博文量
    202
  • 访问量
    518269