4.6.4.5 Obtaining Table Information with myisamchk用myisamchk获取表信息

To obtain a description of a MyISAM table or statistics about it, use the commands shown here. The output from these commands is explained later in this section.要获取MyISAM表的描述或有关它的统计信息,请使用此处显示的命令。本节稍后将解释这些命令的输出。

The tbl_name argument can be either the name of a MyISAM table or the name of its index file, as described in Section 4.6.4, “myisamchk — MyISAM Table-Maintenance Utility”. tbl_name参数可以是MyISAM表的名称,也可以是其索引文件的名称,如第4.6.4节,“myisamchk-MyISAM表维护实用程序”所述。Multiple tbl_name arguments can be given.可以给出多个tbl_name参数。

Suppose that a table named person has the following structure. 假设一个名为person的表具有以下结构。(The MAX_ROWS table option is included so that in the example output from myisamchk shown later, some values are smaller and fit the output format more easily.)(包含MAX_ROWS表选项,以便在稍后显示的myisamchk的示例输出中,一些值更小,更容易适应输出格式。)

CREATE TABLE person
(
  id         INT NOT NULL AUTO_INCREMENT,
  last_name  VARCHAR(20) NOT NULL,
  first_name VARCHAR(20) NOT NULL,
  birth      DATE,
  death      DATE,
  PRIMARY KEY (id),
  INDEX (last_name, first_name),
  INDEX (birth)
) MAX_ROWS = 1000000 ENGINE=MYISAM;

Suppose also that the table has these data and index file sizes:还假设该表具有以下数据和索引文件大小:

-rw-rw----  1 mysql  mysql  9347072 Aug 19 11:47 person.MYD
-rw-rw----  1 mysql  mysql  6066176 Aug 19 11:47 person.MYI

Example of myisamchk -dvv output:myisamchk -dvv输出示例:

MyISAM file:         person
Record format:       Packed
Character set:       utf8mb4_0900_ai_ci (255)
File-version:        1
Creation time:       2017-03-30 21:21:30
Status:              checked,analyzed,optimized keys,sorted index pages
Auto increment key:              1  Last value:                306688
Data records:               306688  Deleted blocks:                 0
Datafile parts:             306688  Deleted data:                   0
Datafile pointer (bytes):        4  Keyfile pointer (bytes):        3
Datafile length:           9347072  Keyfile length:           6066176
Max datafile length:    4294967294  Max keyfile length:   17179868159
Recordlength:                   54

table description:
Key Start Len Index   Type                     Rec/key         Root  Blocksize
1   2     4   unique  long                           1                    1024
2   6     80  multip. varchar prefix                 0                    1024
    87    80          varchar                        0
3   168   3   multip. uint24 NULL                    0                    1024

Field Start Length Nullpos Nullbit Type
1     1     1
2     2     4                      no zeros
3     6     81                     varchar
4     87    81                     varchar
5     168   3      1       1       no zeros
6     171   3      1       2       no zeros

Explanations for the types of information myisamchk produces are given here. 这里给出了myisamchk产生的信息类型的解释。Keyfile refers to the index file. Record and row are synonymous, as are field and column.“Keyfile”指的是索引文件。“记录”和“行”是同义词,“字段”和“列”也是同义词

The initial part of the table description contains these values:表描述的初始部分包含以下值:

The table description part of the output includes a list of all keys in the table. For each key, myisamchk displays some low-level information:输出的table description部分包括表中所有键的列表。对于每个键,myisamchk显示一些低级信息:

The last part of the output provides information about each column:输出的最后一部分提供了有关每一列的信息:

The Huff tree and Bits fields are displayed if the table has been compressed with myisampack. 如果表已使用myisampack压缩,则显示Huff树和Bits字段。See Section 4.6.6, “myisampack — Generate Compressed, Read-Only MyISAM Tables”, for an example of this information.有关此信息的示例,请参阅第4.6.6节,“myisampack——生成压缩的只读MyISAM表”

Example of myisamchk -eiv output:myisamchk -eiv输出示例:

Checking MyISAM file: person
Data records:  306688   Deleted blocks:       0
- check file-size
- check record delete-chain
No recordlinks
- check key delete-chain
block_size 1024:
- check index reference
- check data record references index: 1
Key:  1:  Keyblocks used:  98%  Packed:    0%  Max levels:  3
- check data record references index: 2
Key:  2:  Keyblocks used:  99%  Packed:   97%  Max levels:  3
- check data record references index: 3
Key:  3:  Keyblocks used:  98%  Packed:  -14%  Max levels:  3
Total:    Keyblocks used:  98%  Packed:   89%

- check records and index references
*** LOTS OF ROW NUMBERS DELETED ***

Records:            306688  M.recordlength:       25  Packed:            83%
Recordspace used:       97% Empty space:           2% Blocks/Record:   1.00
Record blocks:      306688  Delete blocks:         0
Record data:       7934464  Deleted data:          0
Lost space:         256512  Linkdata:        1156096

User time 43.08, System time 1.68
Maximum resident set size 0, Integral resident set size 0
Non-physical pagefaults 0, Physical pagefaults 0, Swaps 0
Blocks in 0 out 7, Messages in 0 out 0, Signals 0
Voluntary context switches 0, Involuntary context switches 0
Maximum memory usage: 1046926 bytes (1023k)

myisamchk -eiv output includes the following information:myisamchk -eiv输出包括以下信息: