SQL92 defines two primary character types: char and varchar. Postgres supports these types, in addition to the more general text type, which unlike varchar does not require an upper limit to be declared on the size of the field.
SQL92 では、 char 型と varchar 型という主要な二つの文字データ型を定義して います。 Postgres はどちらもサポート済みです が、それらに加えより汎用性の高い text 型も持って いて、それは varchar 型と違ってフィールドの最大文字数を指定する必 要がありません。
Table 3-5. Postgres 文字データ型
文字データ型 | 記憶領域 | 推奨 | 説明 |
---|---|---|---|
char | 1 byte | SQL92 互換 | 1バイト文字 |
char(n) | (4+n) bytes | SQL92 互換 | 固定長文字列。空白文字で補填される。 |
text | (4+x) bytes | 最良の選択 | 可変長文字 |
varchar(n) | (4+n) bytes | SQL92 互換 | 文字数制限付き可変長文字 |
There is one other fixed-length character type. The name type only has one purpose and that is to provide Postgres with a special type to use for internal names. It is not intended for use by the general user. It's length is currently defined as 32 chars but should be reference using NAMEDATALEN. This is set at compile time and may change in a future release.
あともう1種類、固定長文字列の name 型という文字デー タ型が存在しますが、それは Postgres 内 部で使用する名前の為の特別な型で、一般ユーザに使用される事を意図 されてはいません。現状、これは32文字として定義されていますが、 NAMEDATALEN を使って確認すべきだと思います。データサイズはコンパ イル時に設定されますし、次のバージョンでは変更されるているかも知 れません。
Table 3-6. Postgres 特別な文字データ型
文字データ型 | 記憶領域 | 説明 |
---|---|---|
name | 32 bytes | 32文字固定長、システム内部で使用 |