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 と西ヨーロッパで使用されるキャラクターセットです。
キャラクターセットは名前として許される文字と、ORDER BY
と GROUP BY
コマンドによってソートされる方法を決定します。
キャラクターセットは、名前として使用してもよい文字と SELECT
構文中の
ORDER BY
と GROUP BY
コマンドを用いたソート方法を決定します。
これは、コンパイル時に configure
のスイッチ
--with-charset=charset
によって変更できます。 「4.7.1 素早いインストールの概要」節参照。
MySQL に他のキャラクターセットを追加したい場合は、次を行う必要があります:
MYSET
とします。
ctype_MYSET
, to_lower_MYSET
のようにしなければいけないことに注意してください。
to_lower[]
と to_upper[]
は、それぞれのキャラクターセットに於ける
大文字、小文字の対応を定義した、単純な配列です。
例えば:
to_lower['A'] should contain 'a' to_upper['a'] should contain 'A'
sort_order[]
は文字がどのようにソートされるべきかのマップです。多くのセッ
トでは、これは to_upper[]
と同じです (ケース非依存ソート)。
MySQL は sort_order[character]
の値を元に文字をソートします。
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
CHARSETS_AVAILABLE
リストにキャラクターセット名を追加します。
configure.in
.
マルチバイトのキャラクターセットを作る場合は、_MB マクロを使用します。 `strings/m_ctype.h.in' に次を追加します:
#define MY_CHARSET_MYSET X #if MY_CHARSET_CURRENT == MY_CHARSET_MYSET #define USE_MB #define USE_MB_IDENT #define ismbchar(p, end) (...) #define ismbhead(c) (...) #define mbcharlen(c) (...) #define MBMAXLEN N #endif
Where:
MY_CHARSET_MYSET | 一意のキャラクターセット変数 |
USE_MB | このキャラクターセットはマルチバイト文字( ismbhead() と mbcharlen() で示される) を持つ
|
USE_MB_IDENT | (optional) 定義されていると、テーブル名と項目名にマルチバイト文字が使用できる |
ismbchar(p, e) | p がマルチバイト文字でない場合、あるいはバイト数がマルチバイトの大きさではない場合、0 を返します。
(char*)p から (char*)e-1 で確認できます。
|
ismbhead(c) | もし c がマルチバイト文字の最初の文字ならば、真
|
mbcharlen(c) | マルチバイト文字の大きさ |
MBMAXLEN | キャラクターセット中、一番大きい文字の最大バイト数 |
--log-update=file_name
オプションを使用してmysqld
を起動すると、
データを更新した全てのSQLコマンドをログファイルに書きます。
このログファイルはデータディレクトリにかかれ、
その名前は file_name.#
という形式の名前になっています。
#
は mysqladmin refresh
か mysqladmin flush-logs
を実行する度に、
あるいは FLUSHLOGS
構文を実行したり、サーバーをリスタートする度に
自動的に増える数字です。
もし --log
か -l
オプションを使用した場合、ログファイルの名前は
mysqld
は全部のログを `hostname.log' に書き出します。
この場合、リスタートやりフレッシュを行っても新しくログファイルを作りません。
(一度クローズして再度オープンしますが。)
デフォルトでは、mysql.server
スクリプトは -l
オプションを付加して
MySQL サーバーを起動します。
もし MySQL のパフォーマンスをあげて本番環境などで使用したい場合、
mysql.server
スクリプトから -l
オプションを外してください。
更新ログは、実際に更新されたデータのステートメントだけを書くため、きびきびと動作します。
WHERE
を使用した UPDATE
か DELETE
で結果が得られなかった場合、
ログは書き出されません。
すでにセットされている値に、もう一度項目を更新するような UPDATE
もスキップされます。
ログファイルの更新に従ってデータベースを更新したい場合は、次を行います (更新ログファイル名を `file_name.#' と仮定します):
shell> ls -1 -t -r file_name.[0-9]* | xargs cat | mysql
ls
は全てのログファイルを正しく並べるために使用しています。
これは、クラッシュ後にバックアップした状態まで戻りたい、あるいは、 バックアップした後からクラッシュするまでの間のデータの更新を行いたい、 そんな場合に使えます。
ログは違うホストのデータベースのミラーやマスターデータベースの複製を作る場合にも利用できます。
MySQL 3.22 のテーブルサイズの制限は 4G です。 MySQL 3.23 の新しい MyISAM では、最大のテーブルサイズは 800万テラバイト (2 ^ 63 bytes) です.
しかし、それとは別に OS 自身のファイルサイズの制限があります。 Linuxでは2G、Solaris2.5.1では4G、Solaris2.6では1000Gです。 これは、通常、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.21 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
構文」節参照.
もし大きなテーブルをリードオンリーで使用するなら、myisampack
を使って複数のテーブルを結合したうえで圧縮することができます。myisampack
は少なくとも 50% テーブルを圧縮することができ、その結果、大きなテーブルを使用することができます。
「12.5 MySQL の圧縮された読み込み専用テーブルジェネレータ ( myisampack
・ pack_isam
)」節参照.
他の方法として、"同じような"テーブルを一つにできる MERGE ライブラリーを含む方法があります。 ("同じような" とは、同じ項目情報をもって全てのテーブルが作られている状態をさします) MERGE はインデックスをサポートしていないため、同種のテーブルしか走査できません。 これにインデックスの機能を近い将来追加する予定です。
With MySQL you can currently (version 3.23.6) choose between tree basic
table formats. When you create a new table, you can tell MySQL
which table type it should use for the table. MySQL will
always create a .frm
file to hold the table and column
definitions. Depending on the table type the index and data will be
stored in other files.
You can convert tables between different types with the ALTER
TABLE
statement. 「7.8 ALTER TABLE
構文」節参照.
MyISAM
}
MyISAM
is the default table type in MySQL 3.23. It's
based on the ISAM
code and has a lot of useful extensions.
The index is stored in a file with the .MYI
(MYindex) extension
and the data is stored in file with the .MYD
(MYData) extension.
You can check/repair MyISAM
tables with the myisamchk
utility. 「13.6 Using myisamchk
for crash recovery」節参照.
The following is new in MyISAM
:
INSERT
new rows in a table without deleted rows,
at the same times as other threads are reading from the table.
AUTO_INCREMENT
column. MyISAM
will automatically update this on INSERT/UPDATE
. The
AUTO_INCREMENT
value can be reset with myisamchk
. This
will make AUTO_INCREMENT
columns faster and old numbers will not
be reused as with the old ISAM. Note that when a AUTO_INCREMENT
is defined on the end of a multi-part-key the old behavior is still present.
BLOB
and TEXT
columns can be indexed.
NULL
values are allowed in indexed columns. This takes 0-1
bytes/key.
myisamchk
.
MyISAM
file that indicates whether or not the
table was closed correctly. This will soon be used for automatic repair
in the MySQL server.
myisamchk
will now mark tables as checked. myisamchk
--fast
will only check those tables that don't have this mark.
myisamchk -a
stores statistics for key parts (and not only for
whole keys as in ISAM
).
myisampack
can pack BLOB
and VARCHAR
columns.
MyISAM
also supports the following things, which MySQL
will be able to use in the near future.
VARCHAR
type; A VARCHAR
column starts
with a length stored in 2 bytes.
VARCHAR
may have fixed or dynamic record length.
VARCHAR
and CHAR
may be up to 64K.
All key segments have their own language definition. This will enable
MySQL to have different language definitions per column.
UNIQUE
; This will allow
you to have UNIQUE
on any combination of columns in a table. (You
can't search on a UNIQUE
computed index, however.)
MyISAM
is a better implementation of the same
thing. ISAM uses a B-tree
index. The index is stored in a file
with the .ISM
extension and the data is stored in file with the
.ISD
extension. You can check/repair ISAM tables with the
isamchk
utility. 「13.6 Using myisamchk
for crash recovery」節参照. ISAM tables are not
binary portable across OS/Platforms.
ISAM
has the following features/properties:
HEAP
}
HEAP
tables use a hashed index and are stored in memory. This
makes them very fast, but if MySQL crashes you will lose all
data stored in them. HEAP
is very usable as temporary tables!
CREATE TABLE test TYPE=HEAP SELECT ip,SUM(downloads) as down FROM log_table GROUP BY ip; SELECT COUNT(ip),AVG(down) FROM test; DROP TABLE test;Here are some things you should consider when you use
HEAP
tables:
MAX_ROWS
in the CREATE
statement
to ensure that you accidently do not use all memory.
=
and <=>
(but are VERY fast).
HEAP
tables uses a fixed record length format.
HEAP
doesn't support BLOB
/TEXT
columns.
HEAP
doesn't support AUTO_INCREMENT
columns.
HEAP
doesn't support an index on a NULL
column.
HEAP
table (not that normal
with hashed tables).
HEAP
tables are shared between all clients (just like any other
table).
HEAP
tables are allocated in small blocks. The tables
are 100% dynamic (on inserting). No overflow areas and no extra key
space is needed. Deleted rows are put in a linked list and will be
reused when you insert new data into the table.
DELETE FROM heap_table
or
DROP TABLE heap_table
.
HEAP
tables bigger than max_heap_table_size
.
Go to the first, previous, next, last section, table of contents.