This chapter describes the languages MySQL supports, how sorting works in MySQL, and how to add new character sets to MySQL. You will also find information about maximum table sizes in this chapter.
mysqld
は次の言語でエラーメッセージを提供できます: チェコ語, デンマーク語,
オランダ語, 英語(デフォルト), Estonia, フランス語, ドイツ語, ギリシャ語,
ハンガリー語, イタリア語, 日本語, 韓国語,
ノルウェー語, 新ノルウェー
語,ポーランド語, ポルトガル語, スペイン語そしてスウェーデン語。
ある言語で mysqld
を開始するためには --language=lang
また
は -L lang
スイッチの一つを使います:
shell> mysqld --language=swedish
or:
shell> mysqld --language=/usr/local/share/swedish
言語名は全て小文字であることに注意してください。
言語ファイルは(デフォルトでは)次の場所にあります。 `mysql_base_dir/share/LANGUAGE/'.
エラーメッセージファイルを更新したい場合は、 `errmsg.txt' ファイルを編集し、 `errmsg.sys' ファイルを作成するために以下のように実行します:
shell> comp_err errmsg.txt errmsg.sys
もし MySQL を新しいものにアップグレードしたなら、以前修正した部分と同じところに、 新しい `errmsg.txt' ファイルに修正をほどこしてください。
デフォルトでは、MySQL は ISO8859-1 (Latin1) キャラクターセットを使用し ます。これは USA と西ヨーロッパで使用されるキャラクターセットです。
All standard MySQL binaries are compiled with
--with-extra-charsets=complex
. This will add code to all
standard programs to be able to handle latin1
and all multi-byte
character sets within the binary. Other character sets will be
loaded from a character-set definition file when needed.
キャラクターセットは名前として許される文字と、ORDER BY
と GROUP BY
コマンドによってソートされる方法を決定します。
キャラクターセットは、名前として使用してもよい文字と SELECT
構文中の
ORDER BY
と GROUP BY
コマンドを用いたソート方法を決定します。
You can change the character set with the
--default-character-set
option when you start the server.
The character sets available depend on the --with-charset=charset
option to configure
, and the character set configuration files
listed in `SHAREDIR/charsets/Index'.
「4.7.1 素早いインストールの概要」節参照.
If you change the character set when running MySQL (which may also change the sort order), you must run myisamchk -r -q on all tables. Otherwise your indexes may not be ordered correctly.
When a client connects to a MySQL server, the server sends the default character set in use to the client. The client will switch to use this character set for this connection.
One should use mysql_real_escape_string()
when escaping strings
for a SQL query. mysql_real_escape_string()
is identical to the
old mysql_escape_string()
function, except that it takes the MYSQL
connection handle as the first parameter.
If the client is compiled with different paths than where the server is installed and the user who configured MySQL didn't included all character sets in the MySQL binary, one must specify for the client where it can find the additional character sets it will need if the server runs with a different character set than the client.
One can specify this by putting in a MySQL option file:
[client] character-sets-dir=/usr/local/mysql/share/mysql/charsets
where the path points to where the dynamic MySQL character sets are stored.
One can force the client to use specific character set by specifying:
[client] default-character-set=character-set-name
but normally this is never needed.
To add another character set to MySQL, use the following procedure.
Decide if the set is simple or complex. If the character set does not need to use special string collating routines for sorting and does not need multi-byte character support, it is simple. If it needs either of those features, it is complex.
For example, latin1
and danish
are simple charactersets while
big5
or czech
are complex character sets.
In the following section, we have assumed that you name your character
set MYSET
.
For a simple character set do the following:
ctype
array takes up the first 257 words. The
to_lower
, to_upper
and sort_order
arrays take up
256 words each after that.
CHARSETS_AVAILABLE
and
COMPILED_CHARSETS
lists in configure.in
.
For a complex character set do the following:
ctype_MYSET
, to_lower_MYSET
のようにしなければいけないことに注意してください。
This corresponds to the arrays
in the simple character set. 「10.1.3 The character definition arrays」節参照. For a complex
character set
/* * This comment is parsed by configure to create ctype.c, * so don't change it unless you know what you are doing. * * .configure. number_MYSET=MYNUMBER * .configure. strxfrm_multiply_MYSET=N * .configure. mbmaxlen_MYSET=N */The
configure
program uses this comment to include
the character set into the MySQL library automatically.
The strxfrm_multiply and mbmaxlen lines will be explained in
the following sections. Only include them if you the string
collating functions or the multi-byte character set functions,
respectively.
my_strncoll_MYSET()
my_strcoll_MYSET()
my_strxfrm_MYSET()
my_like_range_MYSET()
CHARSETS_AVAILABLE
and
COMPILED_CHARSETS
lists in configure.in
.
The file `sql/share/charsets/README' includes some more instructions.
If you want to have the character set included in the MySQL distribution, mail a patch to internals@lists.mysql.com.
to_lower[]
と to_upper[]
は、それぞれのキャラクターセットに於ける
大文字、小文字の対応を定義した、単純な配列です。
例えば:
to_lower['A'] should contain 'a' to_upper['a'] should contain 'A'
sort_order[]
は文字がどのようにソートされるべきかのマップです。多くのセッ
トでは、これは to_upper[]
と同じです (ケース非依存ソート)。
MySQL は sort_order[character]
の値を元に文字をソートします。
For more complicated sorting rules, see
the discussion of string collating below. 「10.1.4 String Collating Support」節参照.
ctype[]
は各文字を説明するビットの配列で、1かたまりのビット列が1文字を定義します。
( to_lower[]
, to_upper[]
,sort_order[]
は、文字の値でインデックスされますが、
ctype[]
は文字の値+1 でインデックスされます。
これは EOF を操作するためにずいぶん前から使われているので、この方法を使用しています。) `m_ctype.h' に次のビットマスクの定義を見ることができます:
#define _U 01 /* Uppercase */ #define _L 02 /* Lowercase */ #define _N 04 /* Numeral (digit) */ #define _S 010 /* Spacing character */ #define _P 020 /* Punctuation */ #define _C 040 /* Control character */ #define _B 0100 /* Blank */ #define _X 0200 /* heXadecimal digit */
それぞれの文字に対する ctype[]
は、文字を確定するために
ビット列と組になっていなければなりません。
たとえば、'A'
は大文字定義 (_U
) と 16進定義 (_X
) 両方ともに
属するので、ctype['A'+1]
は以下の値を含まなくてはなりません:
_U + _X = 01 + 0200 = 0201
If the sorting rules for your language are too complex to be handled
with the simple sort_order[]
table, you need to use the string
collating functions.
Right now the best documentation on this is the character sets that are already implemented. Look at the big5, czech, gbk, sjis, and tis160 character sets for examples.
You must specify the strxfrm_multiply_MYSET=N
value in the
special comment at the top of the file. N
should be set to
the maximum ratio the strings may grow during my_strxfrm_MYSET
(it
must be a positive integer).
If your want to add support for a new character set that includes multi-byte characters, you need to use the multi-byte character functions.
Right now the best documentation on this is the character sets that are
already implemented. Look at the euc_kr, gb2312, gbk, sjis and ujis
character sets for examples. These are implemented in the
ctype-'charset'.c
files in the `strings' directory.
You must specify the mbmaxlen_MYSET=N
value in the special
comment at the top of the source file. N
should be set to the
size in bytes of the largest character in the set.
MySQL バージョン 3.22 のテーブルサイズの制限は 4G です。
MySQL バージョン 3.23 の新しい MyISAM
では、
最大のテーブルサイズは 800万テラバイト(2 ^ 63 bytes) です.
しかし、それとは別に OS 自身のファイルサイズの制限があります。 例えばいくつかの OS では以下のようになっています:
Operating System | File Size Limit |
Linux-Intel 32 bit | 2G, 4G or more, depends on Linux version |
Linux-Alpha | 8T (?) |
Solaris 2.5.1 | 2G (possible 4G with patch) |
Solaris 2.6 | 4G |
Solaris 2.7 Intel | 4G |
Solaris 2.7 ULTRA-SPARC | 8T (?) |
On Linux 2.2 you can get bigger tables than 2G by using the LFS patch for the ext2 file system. On Linux 2.4 there exists also patches for ReiserFS to get support for big files.
これは、通常、MySQL のテーブルサイズは オペーレーティングシステムによって制限されるということです。
By default, MySQL tables have a maximum size of about 4G. You can
check the maximum table size for a table with the SHOW TABLE STATUS
command or with the myisamchk -dv table_name
.
「7.28 SHOW
構文」節参照.
If you need bigger tables than 4G (and your operating system supports
this), you should set the AVG_ROW_LENGTH
and MAX_ROWS
parameter when you create your table. 「7.7 CREATE TABLE
構文」節参照. You can
also set these later with ALTER TABLE
. 「7.8 ALTER TABLE
構文」節参照.
You can go around the operating system file limit for MyISAM
data
files by using the RAID
option. 「7.7 CREATE TABLE
構文」節参照.
もし大きなテーブルをリードオンリーで使用するなら、myisampack
を使って複数のテーブルを結合したうえで圧縮することができます。myisampack
は少なくとも 50% テーブルを圧縮することができ、その結果、大きなテーブルを使用することができます。
「15.12 MySQL の圧縮された読み込み専用テーブルジェネレータ ( myisampack
・ pack_isam
)」節参照.
他の方法として、"同じような"テーブルを一つにできる MERGE ライブラリーを含む方法があります。 「8.2 MERGE Tables」節参照.
Go to the first, previous, next, last section, table of contents.