Go to the first, previous, next, last section, table of contents.


10 MySQL サーバーファンクション

10.1 MySQL がサポートしている言語は?

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' ファイルに修正をほどこしてください。

10.1.1 データとソートに使用されるキャラクターセット

デフォルトでは、MySQL は ISO8859-1 (Latin1) キャラクターセットを使用し ます。これは USA と西ヨーロッパで使用されるキャラクターセットです。

キャラクターセットは名前として許される文字と、ORDER BYGROUP BY コマンドによってソートされる方法を決定します。 キャラクターセットは、名前として使用してもよい文字と SELECT 構文中の ORDER BYGROUP 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 素早いインストールの概要」節参照.

When a client connects to a MySQL server, the server sends the 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 that 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.

On can specify this by putting in a MySQL option file:

[client]
default-set-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:

10.1.2 新しいキャラクターセットの追加

  1. 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 mulit-byte character support, it is simple. If it needs either of those features, it is complex.
  2. If the character set is simple, then create the file `sql/share/charsets/MYSET.conf', and add MYSET the `sql/share/charsets/Index' file. Read the `sql/share/charsets/README' for more instructions.
  3. Add the character set name to the CHARSETS_AVAILABLE and COMPILED_CHARSETS lists in configure.in.
  4. Reconfigure, recompile and test.
  5. If the character set is comples, `strings/ctype-MYSET.c' ファイルを MySQL のソースディレクトリ以下に作成します。
  6. Add MYSET to the end of the `sql/share/charsets/Index' file. Take note of its position in the file - this is its character set number, denoted MYNUMBER below.
  7. 必要な定義されるものを調べるために、既存の `ctype-*.c' ファイルの一つを見てく ださい。このファイル中で使用する配列の名前は、 ctype_MYSET, to_lower_MYSET のようにしなければいけないことに注意してください。 Near the top of the file, place a special comment like this:
    /*
     * 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. to_lower[]to_upper[] は、それぞれのキャラクターセットに於ける 大文字、小文字の対応を定義した、単純な配列です。 例えば:
    to_lower['A'] should contain 'a'
    to_upper['a'] should contain 'A'
    
    sort_order[] は文字がどのようにソートされるべきかのマップです。多くのセッ トでは、これは to_upper[] と同じです (ケース非依存ソート)。 MySQLsort_order[character] の値を元に文字をソートします。 For more complicated sorting rules, see the discussion of string collating below. ctype[] は各文字を説明するビットの配列で、1かたまりのビット列が1文字を定義します。 ( to_lower[], to_upper[],sort_order[]は、文字の値でインデックスされますが、 ctype[]は文字の値+1 でインデックスされます。 これは EOF を操作するためにずいぶん前から使われているので、この方法を使用しています。) `m_ctype.h' に次のビットマスクの定義を見ることができます:
    #define _U      01      /* Upper case */
    #define _L      02      /* Lower case */
    #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
    
  8. Add support for the string collating or multi-byte features needed, as described in the following sections.
  9. CHARSETS_AVAILABLE リストと configure.in の中の COMPILED_CHARSETS リスト にキャラクターセット名を追加します。
  10. configureとコンパイルをしなおし、テストしてください。

10.1.3 String collating support

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).

10.1.4 マルチバイト文字のサポート

If your character set 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.

You must specify the mbmaxlen_MYSET=N value in the special comment at the top of the file. N should be set to the size in bytes of the largest character in the set.

10.2 MySQL はテーブルをどれくらい大きくできるか?

MySQL 3.22 のテーブルサイズの制限は 4G です。 MySQL 3.23 の新しい MyISAM では、最大のテーブルサイズは 800万テラバイト (2 ^ 63 bytes) です.

しかし、それとは別に OS 自身のファイルサイズの制限があります。 例えばいくつかの OS では以下のようになっています:

Linux-Intel 2G (or 4G with reiserfs)
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 (?)

これは、通常、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.23 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構文」節参照.

If you need to have bigger tables than 2G / 4G

もし大きなテーブルをリードオンリーで使用するなら、myisampackを使って複数のテーブルを結合したうえで圧縮することができます。myisampackは少なくとも 50% テーブルを圧縮することができ、その結果、大きなテーブルを使用することができます。 「14.7 MySQL の圧縮された読み込み専用テーブルジェネレータ ( myisampackpack_isam )」節参照.

他の方法として、"同じような"テーブルを一つにできる MERGE ライブラリーを含む方法があります。 ("同じような" とは、同じ項目情報をもって全てのテーブルが作られている状態をさします) MERGE はインデックスをサポートしていないため、同種のテーブルしか走査できません。 これにインデックスの機能を近い将来追加する予定です。


Go to the first, previous, next, last section, table of contents.