数据库和表的标识符与文件系统中的名称之间存在对应关系。对于基本结构,MySQL 将每个表示为数据目录中的一个目录,并且根据存储引擎的不同,每个表可能在相应的数据库目录中由一个或多个文件表示。There is a correspondence between database and table identifiers and names in the file system. For the basic structure, MySQL represents each database as a directory in the data directory, and depending upon the storage engine, each table may be represented by one or more files in the appropriate database directory.
对于数据文件和索引文件,磁盘上的具体表示取决于存储引擎。这些文件可能存储在数据库目录中,或者信息可能存储在单独的文件中。InnoDB 数据存储在 InnoDB 数据文件中。如果你使用 InnoDB 的表空间,则会使用你创建的特定表空间文件。For the data and index files, the exact representation on disk
is storage engine specific. These files may be stored in the
database directory, or the information may be stored in a
separate file. InnoDB data is stored in the
InnoDB data files. If you are using tablespaces with
InnoDB, then the specific tablespace files
you create are used instead.
在数据库或表标识符中,除了 ASCII NUL (X'00') 外,任何字符都是合法的。当 MySQL 创建数据库目录或表文件时,会对在相应文件系统对象中可能有问题的字符进行编码:Any character is legal in database or table identifiers except
ASCII NUL (X'00'). MySQL encodes any
characters that are problematic in the corresponding file system
objects when it creates database directories or table files:
基本拉丁字母 (
a..zA..Z)、数字 (0..9) 和下划线 (_) 会保持原样编码。因此,它们的大小写敏感性直接依赖于文件系统的特性。Basic Latin letters (a..zA..Z), digits (0..9) and underscore (_) are encoded as is. Consequently, their case sensitivity directly depends on file system features.所有其他具有大小写映射的字母表中的国家字母编码如下表所示。代码范围列中的值为 UCS-2 值。All other national letters from alphabets that have uppercase/lowercase mapping are encoded as shown in the following table. Values in the Code Range column are UCS-2 values.
代码范围Code Range 模式Pattern 数量Number 已使用Used 未使用Unused 区块Blocks 00C0..017F [@][0..4][g..z] 5*20= 100 97 3 Latin-1 补充 Latin 扩展-ALatin-1 Supplement + Latin Extended-A 0370..03FF [@][5..9][g..z] 5*20= 100 88 12 希腊文与科普特文Greek and Coptic 0400..052F [@][g..z][0..6] 20*7= 140 137 3 西里尔字母 + 西里尔字母补充Cyrillic + Cyrillic Supplement 0530..058F [@][g..z][7..8] 20*2= 40 38 2 亚美尼亚字母Armenian 2160..217F [@][g..z][9] 20*1= 20 16 4 数字形式Number Forms 0180..02AF [@][g..z][a..k] 20*11=220 203 17 拉丁字母扩展-B + 国际音标扩展Latin Extended-B + IPA Extensions 1E00..1EFF [@][g..z][l..r] 20*7= 140 136 4 拉丁字母扩展附加Latin Extended Additional 1F00..1FFF [@][g..z][s..z] 20*8= 160 144 16 希腊扩展Greek Extended .... .... [@][a..f][g..z] 6*20= 120 0 120 保留RESERVED 24B6..24E9 [@][@][a..z] 26 26 0 带圈字母数字Enclosed Alphanumerics FF21..FF5A [@][a..z][@] 26 26 0 半角及全角形式Halfwidth and Fullwidth forms 序列中的一个字节用于编码字母大小写。例如:
LATIN CAPITAL LETTER A WITH GRAVE被编码为@0G,而LATIN SMALL LETTER A WITH GRAVE被编码为@0g。这里第三个字节(G或g)表示字母大小写。(在不区分大小写的文件系统上,这两个字母被视为相同。)One of the bytes in the sequence encodes lettercase. For example:LATIN CAPITAL LETTER A WITH GRAVEis encoded as@0G, whereasLATIN SMALL LETTER A WITH GRAVEis encoded as@0g. Here the third byte (Gorg) indicates lettercase. (On a case-insensitive file system, both letters are treated as the same.)对于某些区块,例如西里尔文,第二个字节决定字母大小写。对于其他区块,例如 Latin1 补充区块,第三个字节决定字母大小写。如果序列中的两个字节是字母(如希腊语扩展区块),最左边的字母字符表示字母大小写。所有其他字母字节必须使用小写。For some blocks, such as Cyrillic, the second byte determines lettercase. For other blocks, such as Latin1 Supplement, the third byte determines lettercase. If two bytes in the sequence are letters (as in Greek Extended), the leftmost letter character stands for lettercase. All other letter bytes must be in lowercase.
除下划线(
_)以外的所有非字母字符,以及没有大写/小写映射的字母(例如希伯来字母),都使用十六进制表示法进行编码,十六进制数字使用小写字母a..f:All nonletter characters except underscore (_), as well as letters from alphabets that do not have uppercase/lowercase mapping (such as Hebrew) are encoded using hexadecimal representation using lowercase letters for hexadecimal digitsa..f:0x003F -> @003f 0xFFFF -> @ffff
十六进制值对应于
ucs2双字节字符集中的字符值。The hexadecimal values correspond to character values in theucs2double-byte character set.
在 Windows 上,一些名称如 nul、prn 和 aux 在服务器创建对应文件或目录时,会通过在名称后加上 @@@ 来进行编码。为了该数据库对象在不同平台之间的可移植性,这种情况在所有平台上都会发生。On Windows, some names such as nul,
prn, and aux are encoded
by appending @@@ to the name when the server
creates the corresponding file or directory. This occurs on all
platforms for portability of the corresponding database object
between platforms.
如果在模式或表名称中使用,以下名称是保留的,并会被附加 @@@:The following names are reserved and appended with
@@@ if used in schema or table names:
CON
PRN
AUX
NUL
COM1 到 COM9COM1 through COM9
LPT1 到 LPT9LPT1 through LPT9
CLOCK$ 也是这一组保留名称的成员,但它没有附加 @@@,而是附加了 @0024。也就是说,如果 CLOCK$ 被用作模式或表名,它将在文件系统中写为 CLOCK@0024。对于模式或表名中使用 $(美元符号)的情况也同样适用;在文件系统中,它会被替换为 @0024。CLOCK$ is also a member of this group of reserved names, but is
not appended with @@@, but
@0024 instead. That is, if CLOCK$ is used as
a schema or table name, it is written to the file system as
CLOCK@0024. The same is true for any use of
$ (dollar sign) in a schema or table name; it is replaced with
@0024 on the filesystem.
这些名称在附加形式下也会写入 INNODB_TABLES,但在 TABLES 中会以用户输入的未附加形式写入。These names are also written to
INNODB_TABLES in their appended
forms, but are written to TABLES
in their unappended form, as entered by the user.