バージョンごとのドキュメント一覧

CREATE TYPE

CREATE TYPE <refpurpose>define a new data type</refpurpose> — 新しいデータ型を定義する

概要

CREATE TYPE name AS
    ( [ attribute_name data_type [ COLLATE collation ] [, ... ] ] )

CREATE TYPE name AS ENUM
    ( [ 'label' [, ... ] ] )

CREATE TYPE name AS RANGE (
    SUBTYPE = subtype
    [ , SUBTYPE_OPCLASS = subtype_operator_class ]
    [ , COLLATION = collation ]
    [ , CANONICAL = canonical_function ]
    [ , SUBTYPE_DIFF = subtype_diff_function ]
    [ , MULTIRANGE_TYPE_NAME = multirange_type_name ]
)

CREATE TYPE name (
    INPUT = input_function,
    OUTPUT = output_function
    [ , RECEIVE = receive_function ]
    [ , SEND = send_function ]
    [ , TYPMOD_IN = type_modifier_input_function ]
    [ , TYPMOD_OUT = type_modifier_output_function ]
    [ , ANALYZE = analyze_function ]
    [ , SUBSCRIPT = subscript_function ]
    [ , INTERNALLENGTH = { internallength | VARIABLE } ]
    [ , PASSEDBYVALUE ]
    [ , ALIGNMENT = alignment ]
    [ , STORAGE = storage ]
    [ , LIKE = like_type ]
    [ , CATEGORY = category ]
    [ , PREFERRED = preferred ]
    [ , DEFAULT = default ]
    [ , ELEMENT = element ]
    [ , DELIMITER = delimiter ]
    [ , COLLATABLE = collatable ]
)

CREATE TYPE name

説明

<title>Description</title>

<command>CREATE TYPE</command> registers a new data type for use in the current database. The user who defines a type becomes its owner. CREATE TYPEは、現在のデータベースで使用できる新しいデータ型を登録します。 型を定義したユーザがその所有者となります。

If a schema name is given then the type is created in the specified schema. Otherwise it is created in the current schema. The type name must be distinct from the name of any existing type or domain in the same schema. (Because tables have associated data types, the type name must also be distinct from the name of any existing table in the same schema.) スキーマ名が与えられている場合、型は指定されたスキーマに作成されます。 スキーマ名がなければ、その型は現在のスキーマに作成されます。 型名は、同じスキーマにある既存の型もしくはドメインとは、異なる名前にする必要があります (さらに、テーブルはデータ型と関連しているため、データ型名は同じスキーマのテーブル名とも競合しないようにしてください)。

There are five forms of <command>CREATE TYPE</command>, as shown in the syntax synopsis above. They respectively create a <firstterm>composite type</firstterm>, an <firstterm>enum type</firstterm>, a <firstterm>range type</firstterm>, a <firstterm>base type</firstterm>, or a <firstterm>shell type</firstterm>. The first four of these are discussed in turn below. A shell type is simply a placeholder for a type to be defined later; it is created by issuing <command>CREATE TYPE</command> with no parameters except for the type name. Shell types are needed as forward references when creating range types and base types, as discussed in those sections. 上の構文概要に示すように、CREATE TYPEには5つの構文があります。 これらはそれぞれ、複合型, 列挙型範囲型基本型シェル型を作成します。 これらの内最初の4個についてはここで順番に説明します。 シェル型は、後で定義される型用の単なるプレースホルダで、型名以外のパラメータをつけずにCREATE TYPEを実行することで作成されます。 シェル型は、範囲型と基本型を作成するときの前方参照として必要となるもので、それぞれの節で説明します。

複合型

<title>Composite Types</title>

The first form of <command>CREATE TYPE</command> creates a composite type. The composite type is specified by a list of attribute names and data types. An attribute's collation can be specified too, if its data type is collatable. A composite type is essentially the same as the row type of a table, but using <command>CREATE TYPE</command> avoids the need to create an actual table when all that is wanted is to define a type. A stand-alone composite type is useful, for example, as the argument or return type of a function. CREATE TYPEの最初の構文を使用すると、複合型を作成できます。 複合型は、属性名およびデータ型のリストにより指定されます。 データ型の照合順序が設定可能である場合、属性の照合順序も指定することができます。 複合型は本質的にはテーブルの行型と同じです。 しかし、型を定義することだけが必要なのであれば、CREATE TYPEを使用することで、実際のテーブルを作成する必要がなくなります。 スタンドアローンの複合型は、例えば関数の引数や戻り値の型として有用です。

To be able to create a composite type, you must have <literal>USAGE</literal> privilege on all attribute types. 複合型を作成するためには、すべての属性型に対してUSAGE権限を持たなければなりません。

列挙型

<title>Enumerated Types</title>

The second form of <command>CREATE TYPE</command> creates an enumerated (enum) type, as described in <xref linkend="datatype-enum"/>. Enum types take a list of quoted labels, each of which must be less than <symbol>NAMEDATALEN</symbol> bytes long (64 bytes in a standard <productname>PostgreSQL</productname> build). (It is possible to create an enumerated type with zero labels, but such a type cannot be used to hold values before at least one label is added using <link linkend="sql-altertype"><command>ALTER TYPE</command></link>.) CREATE TYPEの2つ目の構文を使用すると、8.7で説明する列挙型(enum)を作成します。 列挙型は、引用符付きのラベルのリストを取ります。 ラベルはNAMEDATALENPostgreSQLの標準のビルドでは64バイト)バイトよりも少ない長さでなければなりません。 (ラベルのない列挙型を作成できますが、ALTER TYPEを使ってラベルを少なくとも1つ追加するまでは、そのような型は値を保持するのに使えません。)

範囲型

<title>Range Types</title>

The third form of <command>CREATE TYPE</command> creates a new range type, as described in <xref linkend="rangetypes"/>. CREATE TYPEの三番目の構文は、8.17で説明する範囲型を新規に作成します。

The range type's <replaceable class="parameter">subtype</replaceable> can be any type with an associated b-tree operator class (to determine the ordering of values for the range type). Normally the subtype's default b-tree operator class is used to determine ordering; to use a non-default operator class, specify its name with <replaceable class="parameter">subtype_opclass</replaceable>. If the subtype is collatable, and you want to use a non-default collation in the range's ordering, specify the desired collation with the <replaceable class="parameter">collation</replaceable> option. 範囲型のsubtypeは、関連する(範囲型の値を順序を決定するための)b-tree演算子クラスを持つ任意の型を取ることができます。 通常、派生元型のデフォルトのb-tree演算子クラスが順序を決定するために使用されます。 デフォルト以外の演算子クラスを使用するためには、subtype_opclassでその名前を指定してください。 派生元型が照合順序変更可能であり、範囲の順序付けでデフォルト以外の照合順序を使用したい場合は、collationオプションで使用したい照合順序を指定してください。

The optional <replaceable class="parameter">canonical</replaceable> function must take one argument of the range type being defined, and return a value of the same type. This is used to convert range values to a canonical form, when applicable. See <xref linkend="rangetypes-defining"/> for more information. Creating a <replaceable class="parameter">canonical</replaceable> function is a bit tricky, since it must be defined before the range type can be declared. To do this, you must first create a shell type, which is a placeholder type that has no properties except a name and an owner. This is done by issuing the command <literal>CREATE TYPE <replaceable>name</replaceable></literal>, with no additional parameters. Then the function can be declared using the shell type as argument and result, and finally the range type can be declared using the same name. This automatically replaces the shell type entry with a valid range type. canonical関数(省略可能)は、定義する範囲型の引数を1つ取り、同じ型の値を返さなければなりません。 これは適切な時に範囲値を正規形式に変換するために使用されます。 詳細については8.17.8を参照してください。 canonical関数を作成することは多少厄介です、というのは、範囲型を定義できるようになる前に定義されている必要があるからです。 このためには、まず、名前と所有者以外の属性を持たないプレースホルダであるシェル型を作成しなければなりません。 これは、他にパラメータをつけずにCREATE TYPE nameを実行することで行われます。 その後、このシェル型を引数と結果として使用する関数を宣言することができます。 最後に同じ名前を用いて範囲型を宣言することができます。 これは自動的にシェル型の項目を有効な範囲型に置き換えます。

The optional <replaceable class="parameter">subtype_diff</replaceable> function must take two values of the <replaceable class="parameter">subtype</replaceable> type as argument, and return a <type>double precision</type> value representing the difference between the two given values. While this is optional, providing it allows much greater efficiency of GiST indexes on columns of the range type. See <xref linkend="rangetypes-defining"/> for more information. subtype_diff関数(省略可能)は、subtype型の2つの値を引数として取り、与えられた2つの値の差異を表すdouble precision型を返さなければなりません。 これは省略することができますが、提供することでその範囲型の列に対するGiSTインデックスの効率を大きく向上させることができます。 詳細については8.17.8を参照してください。

The optional <replaceable class="parameter">multirange_type_name</replaceable> parameter specifies the name of the corresponding multirange type. If not specified, this name is chosen automatically as follows. If the range type name contains the substring <literal>range</literal>, then the multirange type name is formed by replacement of the <literal>range</literal> substring with <literal>multirange</literal> in the range type name. Otherwise, the multirange type name is formed by appending a <literal>_multirange</literal> suffix to the range type name. multirange_type_nameパラメータ(省略可能)は、対応する多重範囲型の名前を指定します。 指定されなければ、この名前は自動的に以下のように選ばれます。 範囲型の名前が部分文字列rangeを含んでいれば、多重範囲型の名前は、範囲型の名前における部分文字列rangemultirangeで置き換えることで作られます。 そうでなければ、多重範囲型の名前は範囲型の名前の末尾に_multirangeを追加することで作られます。

基本型

<title>Base Types</title>

The fourth form of <command>CREATE TYPE</command> creates a new base type (scalar type). To create a new base type, you must be a superuser. (This restriction is made because an erroneous type definition could confuse or even crash the server.) CREATE TYPEの4つ目の構文を使用すると、基本型(スカラ型)を新しく作成できます。 新しい基本型を作成するにはスーパーユーザでなければなりません。 (エラーがある型定義が混乱を招き、サーバがクラッシュすることすらあるため、この制限がなされました。)

The parameters can appear in any order, not only that illustrated above, and most are optional. You must register two or more functions (using <command>CREATE FUNCTION</command>) before defining the type. The support functions <replaceable class="parameter">input_function</replaceable> and <replaceable class="parameter">output_function</replaceable> are required, while the functions <replaceable class="parameter">receive_function</replaceable>, <replaceable class="parameter">send_function</replaceable>, <replaceable class="parameter">type_modifier_input_function</replaceable>, <replaceable class="parameter">type_modifier_output_function</replaceable>, <replaceable class="parameter">analyze_function</replaceable>, and <replaceable class="parameter">subscript_function</replaceable> are optional. Generally these functions have to be coded in C or another low-level language. パラメータは、上述の順番である必要はなく、任意の順番で指定することができ、多くは省略可能です。 型を定義する前に、(CREATE FUNCTIONを用いて)2つ以上の関数を登録しておく必要があります。 サポート関数であるinput_functionoutput_functionは必須です。 receive_function関数、send_function関数、type_modifier_input_function関数、type_modifier_output_function関数、analyze_function関数、およびsubscript_functionは省略可能です。 通常、これらの関数は、C言語やその他の低レベル言語で作成されなければなりません。

The <replaceable class="parameter">input_function</replaceable> converts the type's external textual representation to the internal representation used by the operators and functions defined for the type. <replaceable class="parameter">output_function</replaceable> performs the reverse transformation. The input function can be declared as taking one argument of type <type>cstring</type>, or as taking three arguments of types <type>cstring</type>, <type>oid</type>, <type>integer</type>. The first argument is the input text as a C string, the second argument is the type's own OID (except for array types, which instead receive their element type's OID), and the third is the <literal>typmod</literal> of the destination column, if known (-1 will be passed if not). The input function must return a value of the data type itself. Usually, an input function should be declared STRICT; if it is not, it will be called with a NULL first parameter when reading a NULL input value. The function must still return NULL in this case, unless it raises an error. (This case is mainly meant to support domain input functions, which might need to reject NULL inputs.) The output function must be declared as taking one argument of the new data type. The output function must return type <type>cstring</type>. Output functions are not invoked for NULL values. input_functionは、型のテキストによる外部表現を内部表現形式に変換するものであり、その型用に定義される演算子や関数で使用されます。 output_functionはこの逆の変換を行うものです。 入力関数は、1つのcstring型の引数、あるいは、cstring型、oid型、integer型という3つの引数を取るように宣言されます。 最初の引数にはC言語文字列の入力テキスト、2番目には型自体のOID(配列型の場合は例外で要素の型のOIDとなります)、3番目は、判明していれば対象列のtypmodを渡します (不明な場合は-1を渡します)。 この入力関数では、データ型自身の値を返さなければなりません。 通常入力関数はSTRICTとして宣言しなければなりません。 そうしないと、NULLという入力値を読み取った時、NULLという最初のパラメータを持って呼び出されます。 この場合でもエラーを発生させるのでなければ、関数はNULLを返さなければなりません。 (こうした状況はほとんどの場合、ドメイン入力関数をサポートすることを意図しています。ドメイン入力関数ではNULL入力を拒絶しなければならない可能性があります。) 出力関数は、新しいデータ型の引数を1つ取るように宣言しなければなりません。 出力関数は、cstring型を返さなければなりません。 出力関数はNULL値に対して呼び出されることはありません。

The optional <replaceable class="parameter">receive_function</replaceable> converts the type's external binary representation to the internal representation. If this function is not supplied, the type cannot participate in binary input. The binary representation should be chosen to be cheap to convert to internal form, while being reasonably portable. (For example, the standard integer data types use network byte order as the external binary representation, while the internal representation is in the machine's native byte order.) The receive function should perform adequate checking to ensure that the value is valid. The receive function can be declared as taking one argument of type <type>internal</type>, or as taking three arguments of types <type>internal</type>, <type>oid</type>, <type>integer</type>. The first argument is a pointer to a <type>StringInfo</type> buffer holding the received byte string; the optional arguments are the same as for the text input function. The receive function must return a value of the data type itself. Usually, a receive function should be declared STRICT; if it is not, it will be called with a NULL first parameter when reading a NULL input value. The function must still return NULL in this case, unless it raises an error. (This case is mainly meant to support domain receive functions, which might need to reject NULL inputs.) Similarly, the optional <replaceable class="parameter">send_function</replaceable> converts from the internal representation to the external binary representation. If this function is not supplied, the type cannot participate in binary output. The send function must be declared as taking one argument of the new data type. The send function must return type <type>bytea</type>. Send functions are not invoked for NULL values. receive_functionでは、型のバイナリによる外部表現を内部表現に変換します。この関数は省略可能です。 この関数が与えられない場合、この型ではバイナリ入力を行うことができません。 バイナリ表現の方法は、適度な可搬性を保ちつつ、内部表現への変換コストが小さくなるよう選択すべきです (例えば標準の整数データ型は、外部バイナリ表現としてはネットワークバイトオーダを使用し、内部表現ではマシン固有のバイトオーダを使用します)。 この受信関数では、値が有効かどうかを判定するための適切な検査を行わなければなりません。 受信関数は、internal型の引数1つ、または、internal型とoidinteger型の3つの引数を取るように宣言されます。 最初の引数は受信したバイト文字列を保持するStringInfoバッファへのポインタ、省略可能な引数は、テキスト入力関数の説明と同じです。 受信関数は、データ型自体の値を返す必要があります。 通常受信関数はSTRICTとして宣言しなければなりません。 そうしないと、NULLという入力値を読み取った時、NULLという最初のパラメータを持って呼び出されます。 この場合でも関数はエラーを発生させるのでなければNULLを返さなければなりません。 (こうした状況はほとんどの場合、ドメイン受信関数をサポートすることを意図しています。ドメイン受信関数ではNULL入力を拒絶しなければならない可能性があります。) 同様に、send_functionは、内部表現からバイナリによる外部表現に変換します。この関数も省略可能です。 この関数が与えられない場合、この型ではバイナリ出力を行うことができません。 この送信関数は、新しいデータ型の引数1つを取るように宣言しなければなりません。 送信関数はbytea型を返さなければなりません。 送信関数はNULL値に対して呼び出されません。

You should at this point be wondering how the input and output functions can be declared to have results or arguments of the new type, when they have to be created before the new type can be created. The answer is that the type should first be defined as a <firstterm>shell type</firstterm>, which is a placeholder type that has no properties except a name and an owner. This is done by issuing the command <literal>CREATE TYPE <replaceable>name</replaceable></literal>, with no additional parameters. Then the C I/O functions can be defined referencing the shell type. Finally, <command>CREATE TYPE</command> with a full definition replaces the shell entry with a complete, valid type definition, after which the new type can be used normally. ここで、新しいデータ型を作成する前に入力関数と出力関数を作成する必要があるのに、どのようにしてそれらの関数で新しいデータ型を戻り値や入力として宣言できるのか、疑問に思うかもしれません。 その答えは、まず型が最初にシェル型として定義されます。 これは名称と所有者以外の属性を持たないプレースホルダ型です。 これは、コマンドCREATE TYPE nameを他にパラメータをつけずに発行することで行われます。 この後、Cの入出力関数をこのシェル型を参照するように定義することができます。 最後に完全な定義を持ったCREATE TYPEによって、シェル型の項目が完全かつ有効な型定義に置き換わり、新しい型を普通に使用することができるようになります。

The optional <replaceable class="parameter">type_modifier_input_function</replaceable> and <replaceable class="parameter">type_modifier_output_function</replaceable> are needed if the type supports modifiers, that is optional constraints attached to a type declaration, such as <literal>char(5)</literal> or <literal>numeric(30,2)</literal>. <productname>PostgreSQL</productname> allows user-defined types to take one or more simple constants or identifiers as modifiers. However, this information must be capable of being packed into a single non-negative integer value for storage in the system catalogs. The <replaceable class="parameter">type_modifier_input_function</replaceable> is passed the declared modifier(s) in the form of a <type>cstring</type> array. It must check the values for validity (throwing an error if they are wrong), and if they are correct, return a single non-negative <type>integer</type> value that will be stored as the column <quote>typmod</quote>. Type modifiers will be rejected if the type does not have a <replaceable class="parameter">type_modifier_input_function</replaceable>. The <replaceable class="parameter">type_modifier_output_function</replaceable> converts the internal integer typmod value back to the correct form for user display. It must return a <type>cstring</type> value that is the exact string to append to the type name; for example <type>numeric</type>'s function might return <literal>(30,2)</literal>. It is allowed to omit the <replaceable class="parameter">type_modifier_output_function</replaceable>, in which case the default display format is just the stored typmod integer value enclosed in parentheses. type_modifier_input_functiontype_modifier_output_functionは必須ではありませんが、型が修飾子をサポートする場合は必要です。 修飾子とは、char(5)numeric(30,2)などの型宣言に付与されるオプションの制約です。 PostgreSQLでは、ユーザ定義型が1つ以上の整数定数または識別子を修飾子として取ることができます。 しかし、この情報はシステムカタログに格納される時に0以上の整数1つにまとめられるものでなければなりません。 type_modifier_input_functionには、cstring型配列の形で宣言された修飾子が渡されます。 その値について妥当性を検査しなければなりません(不当な場合はエラーとします)。 そして、正しい場合は、typmod列として格納される、0以上のinteger値を1つ返さなければなりません。 型がtype_modifier_input_functionを持たない場合、型修飾子は拒否されます。 type_modifier_output_functionは内部的な整数typmod値をユーザ側の表示に合わせて変換します。 この関数は型名に付与する正確な文字列となるcstring値を返さなければなりません。 たとえばnumeric用の関数では(30,2)を返すかもしれません。 デフォルトの表示用書式が保管されたtypmod整数値を括弧で括ったものと一致している場合は、type_modifier_output_functionを省略することができます。

The optional <replaceable class="parameter">analyze_function</replaceable> performs type-specific statistics collection for columns of the data type. By default, <command>ANALYZE</command> will attempt to gather statistics using the type's <quote>equals</quote> and <quote>less-than</quote> operators, if there is a default b-tree operator class for the type. For non-scalar types this behavior is likely to be unsuitable, so it can be overridden by specifying a custom analysis function. The analysis function must be declared to take a single argument of type <type>internal</type>, and return a <type>boolean</type> result. The detailed API for analysis functions appears in <filename>src/include/commands/vacuum.h</filename>. オプションのanalyze_functionは、このデータ型の列に対する、型固有の統計情報の収集を行います。 その型用のデフォルトのB-tree演算子クラスがあれば、ANALYZEはデフォルトでは型の等価演算子と小なり演算子を使用して統計情報を集めようと試みます。 非スカラ型には、この振舞いはあまり適していません。 そのため、独自の解析関数を指定することで、この振舞いを上書きすることができます。 この解析関数は、internal型の引数を1つ取り、戻り値としてbooleanを返すように宣言する必要があります。 解析関数用のAPIの詳細は、src/include/commands/vacuum.hにあります。

The optional <replaceable class="parameter">subscript_function</replaceable> allows the data type to be subscripted in SQL commands. Specifying this function does not cause the type to be considered a <quote>true</quote> array type; for example, it will not be a candidate for the result type of <literal>ARRAY[]</literal> constructs. But if subscripting a value of the type is a natural notation for extracting data from it, then a <replaceable class="parameter">subscript_function</replaceable> can be written to define what that means. The subscript function must be declared to take a single argument of type <type>internal</type>, and return an <type>internal</type> result, which is a pointer to a struct of methods (functions) that implement subscripting. The detailed API for subscript functions appears in <filename>src/include/nodes/subscripting.h</filename>. It may also be useful to read the array implementation in <filename>src/backend/utils/adt/arraysubs.c</filename>, or the simpler code in <filename>contrib/hstore/hstore_subs.c</filename>. Additional information appears in <xref linkend="sql-createtype-array"/> below. オプションのsubscript_functionは、SQLコマンド内で指定されたデータ型に添字をつけることを許可します。 この関数を指定することで、指定されたデータ型が真の配列型とみなされる訳ではありません。たとえば、ARRAY[]生成の結果型の候補にはなりません。 ですが、その型の値に添字をつけることが、そこからデータを取り出す自然な表記法であるなら、その意味を定義するのにsubscript_functionを書くことができます。 添字関数はinternal型の引数を1つ取り、添字を実装しているメソッド(関数)の構造体へのポインタであるinternalの結果を返すよう宣言しなければなりません。 添字関数の詳細なAPIはsrc/include/nodes/subscripting.hにあります。 src/backend/utils/adt/arraysubs.cにある配列の実装やcontrib/hstore/hstore_subs.cにあるより単純なコードを読むのも有用かもしれません。 追加の情報は以下の配列型にあります。

While the details of the new type's internal representation are only known to the I/O functions and other functions you create to work with the type, there are several properties of the internal representation that must be declared to <productname>PostgreSQL</productname>. Foremost of these is <replaceable class="parameter">internallength</replaceable>. Base data types can be fixed-length, in which case <replaceable class="parameter">internallength</replaceable> is a positive integer, or variable-length, indicated by setting <replaceable class="parameter">internallength</replaceable> to <literal>VARIABLE</literal>. (Internally, this is represented by setting <literal>typlen</literal> to -1.) The internal representation of all variable-length types must start with a 4-byte integer giving the total length of this value of the type. (Note that the length field is often encoded, as described in <xref linkend="storage-toast"/>; it's unwise to access it directly.) 新しい型の内部表現の詳細を理解しなければならないのは、これらのI/O関数とその型に関連して動作するユーザ定義の関数のみですが、内部表現には、PostgreSQLに対し宣言しなければならない複数の属性値があります。 属性の中で最も重要なものはinternallengthです。 基本データ型は、internallengthに正の整数を指定して固定長として作成するだけでなく、internallengthVARIABLEと設定し可変長として作成することもできます (内部的には、これはtyplenを-1に設定することで表現されます)。 全ての可変長型の内部表現は、型の値の全長を示す4バイトの整数値から始まらなければなりません。 (長さフィールドは多くの場合73.2に記述されているようにエンコードされており、それに直接アクセスすることは賢明ではないことに注意してください。)

The optional flag <literal>PASSEDBYVALUE</literal> indicates that values of this data type are passed by value, rather than by reference. Types passed by value must be fixed-length, and their internal representation cannot be larger than the size of the <type>Datum</type> type (4 bytes on some machines, 8 bytes on others). オプションのPASSEDBYVALUEフラグは、このデータ型の値が参照ではなく値によって渡されることを示します。 値によって渡される型は固定長でなければならず、その内部表現はDatum型のサイズ(4バイトのマシンもあれば8バイトのマシンもあります)を超えてはいけません。

The <replaceable class="parameter">alignment</replaceable> parameter specifies the storage alignment required for the data type. The allowed values equate to alignment on 1, 2, 4, or 8 byte boundaries. Note that variable-length types must have an alignment of at least 4, since they necessarily contain an <type>int4</type> as their first component. alignmentパラメータは、そのデータ型の格納の際に必要な整列を指定します。 設定可能な値は、1、2、4、8バイト境界での整列です。 可変長の型は最低でも4の整列を持たなければならないことに注意してください。 最初の要素としてint4を持たなければならないからです。

The <replaceable class="parameter">storage</replaceable> parameter allows selection of storage strategies for variable-length data types. (Only <literal>plain</literal> is allowed for fixed-length types.) <literal>plain</literal> specifies that data of the type will always be stored in-line and not compressed. <literal>extended</literal> specifies that the system will first try to compress a long data value, and will move the value out of the main table row if it's still too long. <literal>external</literal> allows the value to be moved out of the main table, but the system will not try to compress it. <literal>main</literal> allows compression, but discourages moving the value out of the main table. (Data items with this storage strategy might still be moved out of the main table if there is no other way to make a row fit, but they will be kept in the main table preferentially over <literal>extended</literal> and <literal>external</literal> items.) storageパラメータを使用することで、可変長データ型を格納する際の戦略を選択することができます (固定長の型にはplainのみが使用できます)。 plainを指定すると、その型のデータは常にインラインで格納され、圧縮されません。 extendedを指定すると、システムはまず長いデータ値を圧縮しようとし、それでもまだ長過ぎる場合は値をメインテーブルの行から削除して移動します。 externalはメインテーブルから値を削除して移動することを許しますが、システムはデータを圧縮しようとしません。 mainはデータの圧縮を許しますが、できるだけ値をメインテーブルから削除しないようにします (行を収めるために他に方法がない場合にはメインテーブルから削除されてしまう可能性がありますが、extendedexternalが指定されたアイテムよりも優先してメインテーブルに残されます)。

All <replaceable class="parameter">storage</replaceable> values other than <literal>plain</literal> imply that the functions of the data type can handle values that have been <firstterm>toasted</firstterm>, as described in <xref linkend="storage-toast"/> and <xref linkend="xtypes-toast"/>. The specific other value given merely determines the default TOAST storage strategy for columns of a toastable data type; users can pick other strategies for individual columns using <literal>ALTER TABLE SET STORAGE</literal>. plainを除くすべてのstorageの値は、そのデータ型の関数が、73.2および38.13.1に記述されているようにtoastされた値を処理できることを暗示します。 その他の特定の値を指定するのは、TOAST可能なデータ型の列について、単にデフォルトのTOAST戦略を決めるだけです。 ユーザは個々の列についてALTER TABLE SET STORAGEを使って他の戦略を選択できます。

The <replaceable class="parameter">like_type</replaceable> parameter provides an alternative method for specifying the basic representation properties of a data type: copy them from some existing type. The values of <replaceable class="parameter">internallength</replaceable>, <replaceable class="parameter">passedbyvalue</replaceable>, <replaceable class="parameter">alignment</replaceable>, and <replaceable class="parameter">storage</replaceable> are copied from the named type. (It is possible, though usually undesirable, to override some of these values by specifying them along with the <literal>LIKE</literal> clause.) Specifying representation this way is especially useful when the low-level implementation of the new type <quote>piggybacks</quote> on an existing type in some fashion. like_typeパラメータは、何らかの既存のデータ型から複製するという、データ型の基本表現プロパティを指定する、別の方法を提供します。 internallengthpassedbyvaluealignmentstorageの値が指定された型から複製されます。 (通常は望ましくありませんが、LIKE句と一緒にこれらの値を指定することで、値を上書きすることも可能です。) 新しい型の低レベル実装にある流儀に従った既存の型を移す時に、この方法で表現を指定することが特に有用です。

The <replaceable class="parameter">category</replaceable> and <replaceable class="parameter">preferred</replaceable> parameters can be used to help control which implicit cast will be applied in ambiguous situations. Each data type belongs to a category named by a single ASCII character, and each type is either <quote>preferred</quote> or not within its category. The parser will prefer casting to preferred types (but only from other types within the same category) when this rule is helpful in resolving overloaded functions or operators. For more details see <xref linkend="typeconv"/>. For types that have no implicit casts to or from any other types, it is sufficient to leave these settings at the defaults. However, for a group of related types that have implicit casts, it is often helpful to mark them all as belonging to a category and select one or two of the <quote>most general</quote> types as being preferred within the category. The <replaceable class="parameter">category</replaceable> parameter is especially useful when adding a user-defined type to an existing built-in category, such as the numeric or string types. However, it is also possible to create new entirely-user-defined type categories. Select any ASCII character other than an upper-case letter to name such a category. categorypreferredパラメータは、あいまいな状況でどの暗黙的なキャストが適用されるかについての制御を補助するために使用することができます。 各データ型は単一のASCII文字で命名されるカテゴリに属しており、各型はそのカテゴリ内で優先される(preferred)か否かです。 オーバーロードされた関数または演算子の解決に、この規則が有用な場合には、パーサは優先される型へのキャストを優先します(ただし、同一のカテゴリ内の他の型からだけです)。 より詳細は第10章を参照してください。 他の型への、または、ほかの型からの暗黙的なキャストを持たない型では、これらの設定をデフォルトのままにしておくことで十分です。 しかし、暗黙的なキャストを持つ関連する型のグループでは、それらすべてを1つのカテゴリに属すものとし、最も汎用的な型の1つまたは2つをカテゴリ内で優先されるものとして選択することが有用となる場合が多くあります。 ユーザ定義型を、数値型や文字列型などの既存の組み込みカテゴリに追加する場合に、categoryパラメータは特に有用です。 しかし、完全にユーザ定義の新しい型カテゴリを作成することもできます。 そのようなカテゴリの命名には大文字以外の任意のASCII文字を選択してください。

A default value can be specified, in case a user wants columns of the data type to default to something other than the null value. Specify the default with the <literal>DEFAULT</literal> key word. (Such a default can be overridden by an explicit <literal>DEFAULT</literal> clause attached to a particular column.) ユーザがそのデータ型の列のデフォルトをNULL以外にしたい場合は、デフォルト値を指定することができます。 デフォルト値はDEFAULTキーワードで指定してください。 (この方法で指定されたデフォルト値を、特定の列に付与された、明示的なDEFAULT句によって上書きすることができます。)

To indicate that a type is a fixed-length array type, specify the type of the array elements using the <literal>ELEMENT</literal> key word. For example, to define an array of 4-byte integers (<type>int4</type>), specify <literal>ELEMENT = int4</literal>. For more details, see <xref linkend="sql-createtype-array"/> below. データ型が固定長の配列型であることを示すには、ELEMENTキーワードを使用して配列要素の型を指定してください。 例えば、4バイト整数(int4)の配列を定義するには、ELEMENT = int4と指定してください。 より詳細は以下の配列型を参照してください。

To indicate the delimiter to be used between values in the external representation of arrays of this type, <replaceable class="parameter">delimiter</replaceable> can be set to a specific character. The default delimiter is the comma (<literal>,</literal>). Note that the delimiter is associated with the array element type, not the array type itself. この型による配列の外部形式における値間の区切り文字を示すために、delimiterで特定の文字を設定することができます。 デフォルトの区切り文字はカンマ(',')です。 この区切り文字は、配列要素の型に関係するものであり、配列型自体に関係するものでないことに注意してください。

If the optional Boolean parameter <replaceable class="parameter">collatable</replaceable> is true, column definitions and expressions of the type may carry collation information through use of the <literal>COLLATE</literal> clause. It is up to the implementations of the functions operating on the type to actually make use of the collation information; this does not happen automatically merely by marking the type collatable. 論理型のcollatableパラメータ(省略可能)が真の場合、COLLATE句を使用することによって、型の列定義と式は照合順序情報を持つことができます。 照合順序情報を実際に使用するかどうかは、型に対する操作を行う関数実装に任されています。 照合順序を設定可能な型を作成することにより、これが自動的に行われることはありません。

<refsect2 id="sql-createtype-array" xreflabel="Array Types"> <title>Array Types</title>

配列型

Whenever a user-defined type is created, <productname>PostgreSQL</productname> automatically creates an associated array type, whose name consists of the element type's name prepended with an underscore, and truncated if necessary to keep it less than <symbol>NAMEDATALEN</symbol> bytes long. (If the name so generated collides with an existing type name, the process is repeated until a non-colliding name is found.) This implicitly-created array type is variable length and uses the built-in input and output functions <literal>array_in</literal> and <literal>array_out</literal>. Furthermore, this type is what the system uses for constructs such as <literal>ARRAY[]</literal> over the user-defined type. The array type tracks any changes in its element type's owner or schema, and is dropped if the element type is. ユーザ定義型が作成されると、PostgreSQLは、自動的に関連する配列型を作成します。 その要素型の名前の前にアンダースコアを付け、必要に応じてNAMEDATALEN長より短くなるように切り詰められた名前になります。 (こうして付けられた名前が既存の型名と競合する場合、競合する名称がなくなるまでこの処理が繰り返されます。) この暗黙的に作成される配列型は可変長で、組み込み入出力関数array_inarray_outを使用します。 さらに、この型は、ユーザ定義型に対してシステムがARRAY[]のように構成時に使うものです。 配列型はその要素となる型の所有者とスキーマのなんらかの変更に追従し、また、要素となる型が削除された場合に削除されます。

You might reasonably ask why there is an <option>ELEMENT</option> option, if the system makes the correct array type automatically. The main case where it's useful to use <option>ELEMENT</option> is when you are making a fixed-length type that happens to be internally an array of a number of identical things, and you want to allow these things to be accessed directly by subscripting, in addition to whatever operations you plan to provide for the type as a whole. For example, type <type>point</type> is represented as just two floating-point numbers, which can be accessed using <literal>point[0]</literal> and <literal>point[1]</literal>. Note that this facility only works for fixed-length types whose internal form is exactly a sequence of identical fixed-length fields. For historical reasons (i.e., this is clearly wrong but it's far too late to change it), subscripting of fixed-length array types starts from zero, rather than from one as for variable-length arrays. 「システムが自動的に配列型を正しく作成するのであれば、ELEMENTオプションはどうして存在するのだろう」と疑問に思うのも道理です。 ELEMENTが意味を持つ、主な場合は次のような条件を満たす固定長の型を作成する時です。 その条件とは、内部的に複数の同一の要素からなる配列となっていること、その配列に対して添字を指定して直接アクセスできること、加えて、今後作成する型全体に対する操作がどのようなものであっても、それらから直接アクセスできることです。 例えば、point型は、2つの浮動小数点だけから構成され、それらはpoint[0]およびpoint[1]を用いてアクセスすることができます。 この機能は、その内部形式が同一の固定長フィールドの正確な並びである、固定長の型でのみ動作することに注意してください。 歴史的な理由(明らかに間違いなのですが、変更するには遅すぎたため)により、固定長配列型への要素番号指定は0から始まり、可変長配列の場合は1から始まります。

Specifying the <option>SUBSCRIPT</option> option allows a data type to be subscripted, even though the system does not otherwise regard it as an array type. The behavior just described for fixed-length arrays is actually implemented by the <option>SUBSCRIPT</option> handler function <function>raw_array_subscript_handler</function>, which is used automatically if you specify <option>ELEMENT</option> for a fixed-length type without also writing <option>SUBSCRIPT</option>. SUBSCRIPTオプションを指定すると、たとえシステムが配列型とみなさない場合でも、データ型に添字をつけることができるようになります。 固定長の配列について述べた振舞いは、実はSUBSCRIPTハンドラ関数raw_array_subscript_handlerにより実装されており、固定長型に対してSUBSCRIPTを書かずにELEMENTを指定した場合には自動的に、この関数が使われます。

When specifying a custom <option>SUBSCRIPT</option> function, it is not necessary to specify <option>ELEMENT</option> unless the <option>SUBSCRIPT</option> handler function needs to consult <structfield>typelem</structfield> to find out what to return. Be aware that specifying <option>ELEMENT</option> causes the system to assume that the new type contains, or is somehow physically dependent on, the element type; thus for example changing properties of the element type won't be allowed if there are any columns of the dependent type. カスタムのSUBSCRIPT関数を指定した場合には、SUBSCRIPTハンドラ関数が何を返すべきか見つけるためにtypelemを調べる必要がない限り、ELEMENTを指定することは必要ではありません。 ELEMENTを指定すると、新しい型が要素型を含んでいる、すなわち要素型に何らかの形で物理的に依存しているとシステムが仮定することに注意してください。このため、例えば、依存する型の列があれば要素型の属性を変更することはできません。

パラメータ

<title>Parameters</title>
name

The name (optionally schema-qualified) of a type to be created. 作成するデータ型の名前です(スキーマ修飾名も可)。

attribute_name

The name of an attribute (column) for the composite type. 複合型用の属性(列)名です。

data_type

The name of an existing data type to become a column of the composite type. 複合型の列となる、既存のデータ型の名前です。

collation

The name of an existing collation to be associated with a column of a composite type, or with a range type. 複合型の列または範囲型に関連付けされる、既存の照合順序の名前です。

label

A string literal representing the textual label associated with one value of an enum type. 列挙型の1つの値に関連付けられるテキスト形式のラベルを表す、文字列リテラルです。

subtype

The name of the element type that the range type will represent ranges of. 範囲型がその範囲の対象として表現する、要素型の名前です。

subtype_operator_class

The name of a b-tree operator class for the subtype. 派生元型のb-tree演算子クラスの名前です。

canonical_function

The name of the canonicalization function for the range type. 範囲型の正規化関数の名前です。

subtype_diff_function

The name of a difference function for the subtype. 派生元型の差異をとる関数の名前です。

multirange_type_name

The name of the corresponding multirange type. 対応する多重範囲型の名前です。

input_function

The name of a function that converts data from the type's external textual form to its internal form. 指定された型のテキストによる外部形式のデータを内部形式に変換する関数の名前です。

output_function

The name of a function that converts data from the type's internal form to its external textual form. 指定された型の内部形式のデータをテキストによる外部形式に変換する関数の名前です。

receive_function

The name of a function that converts data from the type's external binary form to its internal form. 指定された型のバイナリによる外部形式のデータを内部形式に変換する関数の名前です。

send_function

The name of a function that converts data from the type's internal form to its external binary form. 指定された型の内部形式のデータをバイナリによる外部形式に変換する関数の名前です。

type_modifier_input_function

The name of a function that converts an array of modifier(s) for the type into internal form. 型に関する修飾子の配列を内部形式に変換する関数の名前です。

type_modifier_output_function

The name of a function that converts the internal form of the type's modifier(s) to external textual form. 内部形式の型修飾子をテキストの外部形式に変換する関数の名前です。

analyze_function

The name of a function that performs statistical analysis for the data type. 指定したデータ型の統計情報解析を行う関数の名前です。

subscript_function

The name of a function that defines what subscripting a value of the data type does. 指定したデータ型の値に添字をつけることを定義する関数の名前です。

internallength

A numeric constant that specifies the length in bytes of the new type's internal representation. The default assumption is that it is variable-length. 新しいデータ型の内部表現のバイト長を表す数値定数です。 デフォルトでは、可変長であるとみなされます。

alignment

The storage alignment requirement of the data type. If specified, it must be <literal>char</literal>, <literal>int2</literal>, <literal>int4</literal>, or <literal>double</literal>; the default is <literal>int4</literal>. データ型の格納整列条件です。 このオプションを指定する場合は、charint2int4doubleのいずれかでなければなりません。 デフォルトはint4です。

storage

The storage strategy for the data type. If specified, must be <literal>plain</literal>, <literal>external</literal>, <literal>extended</literal>, or <literal>main</literal>; the default is <literal>plain</literal>. データ型の格納戦略です。 このオプションを指定する場合は、plainexternalextendedmainのいずれかでなければなりません。 デフォルトはplainです。

like_type

The name of an existing data type that the new type will have the same representation as. The values of <replaceable class="parameter">internallength</replaceable>, <replaceable class="parameter">passedbyvalue</replaceable>, <replaceable class="parameter">alignment</replaceable>, and <replaceable class="parameter">storage</replaceable> are copied from that type, unless overridden by explicit specification elsewhere in this <command>CREATE TYPE</command> command. 新しい型に同じ表現を持たせる既存のデータ型の名前です。 internallengthpassedbyvaluealignmentstorageの値が、このCREATE TYPEコマンドのどこかで明示的な指定により上書きされない限り、型から複製されます。

category

The category code (a single ASCII character) for this type. The default is <literal>'U'</literal> for <quote>user-defined type</quote>. Other standard category codes can be found in <xref linkend="catalog-typcategory-table"/>. You may also choose other ASCII characters in order to create custom categories. この型用のカテゴリコード(単一のASCII文字)です。 デフォルトはユーザ定義型を表す'U'です。 他の標準カテゴリコードを表 53.65に示します。 独自のカテゴリを作成するために他のASCII文字を選択することもできます。

preferred

True if this type is a preferred type within its type category, else false. The default is false. Be very careful about creating a new preferred type within an existing type category, as this could cause surprising changes in behavior. この型がカテゴリ内で優先される型である場合に真、さもなくば偽です。 デフォルトは偽です。 動作に予想外の変化を引き起こしますので既存の型カテゴリに新しく優先される型を作成することには十分注意してください。

default

The default value for the data type. If this is omitted, the default is null. そのデータ型のデフォルト値です。 省略された場合、デフォルトはNULLです。

element

The type being created is an array; this specifies the type of the array elements. 配列型を作成する場合、その配列の要素の型を指定します。

delimiter

The delimiter character to be used between values in arrays made of this type. このデータ型による配列で、値間の区切り文字として使われる文字です。

collatable

True if this type's operations can use collation information. The default is false. この型を操作する時に照合順序情報を使用することができる場合に真を取ります。 デフォルトは偽です。

注釈

<title>Notes</title>

Because there are no restrictions on use of a data type once it's been created, creating a base type or range type is tantamount to granting public execute permission on the functions mentioned in the type definition. This is usually not an issue for the sorts of functions that are useful in a type definition. But you might want to think twice before designing a type in a way that would require <quote>secret</quote> information to be used while converting it to or from external form. 一度作成したデータ型の使用には制限はありませんので、基本型または範囲型の作成は型定義で言及した関数の実行権をPUBLICに対して付与することと同じです。 この種の型定義において有用な関数では、これは通常問題になりません。 しかし、外部形式から、または、外部形式への変換を行う時に、その関数が秘密の情報を必要とする場合、型を設計する前に熟考してください。

Before <productname>PostgreSQL</productname> version 8.3, the name of a generated array type was always exactly the element type's name with one underscore character (<literal>_</literal>) prepended. (Type names were therefore restricted in length to one fewer character than other names.) While this is still usually the case, the array type name may vary from this in case of maximum-length names or collisions with user type names that begin with underscore. Writing code that depends on this convention is therefore deprecated. Instead, use <structname>pg_type</structname>.<structfield>typarray</structfield> to locate the array type associated with a given type. PostgreSQLバージョン8.3より前のバージョンでは、生成される配列型の名前は常に要素型の名前の前に1つのアンダースコア文字(_)を付けたものになりました。 (このため型の名前は他の名前よりも1文字短く制限されていました。) 通常はこのように名付けられることは変わりありませんが、最大長の名前の場合やアンダースコアから始まるユーザ定義の型と競合する場合、配列型の名前はこの変換とは変わることがあります。 このため、この規則に依存したコードを書くことは避けてください。 代わりに、pg_type.typarrayを使用して、指定した型に関連した配列型を特定してください。

It may be advisable to avoid using type and table names that begin with underscore. While the server will change generated array type names to avoid collisions with user-given names, there is still risk of confusion, particularly with old client software that may assume that type names beginning with underscores always represent arrays. アンダースコアから始まる型やテーブル名の使用を避けることが賢明です。 サーバは生成された配列型名称をユーザ指定の名前と競合しないように変更しますが、混乱する危険があります。 特に古いクライアントソフトウェアを使用する場合、名前がアンダースコアから始まる型を常に配列を表すものと想定しているかもしれません。

Before <productname>PostgreSQL</productname> version 8.2, the shell-type creation syntax <literal>CREATE TYPE <replaceable>name</replaceable></literal> did not exist. The way to create a new base type was to create its input function first. In this approach, <productname>PostgreSQL</productname> will first see the name of the new data type as the return type of the input function. The shell type is implicitly created in this situation, and then it can be referenced in the definitions of the remaining I/O functions. This approach still works, but is deprecated and might be disallowed in some future release. Also, to avoid accidentally cluttering the catalogs with shell types as a result of simple typos in function definitions, a shell type will only be made this way when the input function is written in C. PostgreSQLバージョン8.2より前まででは、シェル型を作成するCREATE TYPE name構文は存在しません。 新規に基本型を作成する方法は、最初に入力関数を作成することでした。 この方法では、PostgreSQLは新しいデータ型の名称を、入力関数の戻り値型で初めて見ます。 このときに、シェル型が暗黙的に作成され、残りの入出力関数の定義で参照することができます。 この方法もまだ使用できますが、廃止予定であり、将来のリリースで禁止される可能性があります。 また、関数定義における単純なタイプミスの結果作成されるシェル型によって起こるカタログの混乱を防止するため、入力関数がCで作成された場合にのみこの方法によってシェル型が作成されます。

In <productname>PostgreSQL</productname> version 16 and later, it is desirable for base types' input functions to return <quote>soft</quote> errors using the new <function>errsave()</function>/<function>ereturn()</function> mechanism, rather than throwing <function>ereport()</function> exceptions as in previous versions. See <filename>src/backend/utils/fmgr/README</filename> for more information. PostgreSQLバージョン16以降では、以前のバージョンのようにereport()例外を発生するのではなく、新しいerrsave()/ereturn()機構を使用して、基本型の入力関数がソフトなエラーを返すことが望ましいです。 詳細については、src/backend/utils/fmgr/READMEを参照してください。

<title>Examples</title>

This example creates a composite type and uses it in a function definition: 次の例では、複合型を作成し、それを関数定義で使用します。

CREATE TYPE compfoo AS (f1 int, f2 text);

CREATE FUNCTION getfoo() RETURNS SETOF compfoo AS $$
    SELECT fooid, fooname FROM foo
$$ LANGUAGE SQL;

This example creates an enumerated type and uses it in a table definition: 次の例では、列挙型を作成し、それをテーブル定義に使用します。

CREATE TYPE bug_status AS ENUM ('new', 'open', 'closed');

CREATE TABLE bug (
    id serial,
    description text,
    status bug_status
);

This example creates a range type: 次の例では、範囲型を作成します。

CREATE TYPE float8_range AS RANGE (subtype = float8, subtype_diff = float8mi);

This example creates the base data type <type>box</type> and then uses the type in a table definition: 次の例では、基本データ型boxを作成し、その型をテーブル定義の中で使用しています。

CREATE TYPE box;

CREATE FUNCTION my_box_in_function(cstring) RETURNS box AS ... ;
CREATE FUNCTION my_box_out_function(box) RETURNS cstring AS ... ;

CREATE TYPE box (
    INTERNALLENGTH = 16,
    INPUT = my_box_in_function,
    OUTPUT = my_box_out_function
);

CREATE TABLE myboxes (
    id integer,
    description box
);

If the internal structure of <type>box</type> were an array of four <type>float4</type> elements, we might instead use: box型の内部構造がfloat4型が4つの配列の場合、このように書き換えることもできます。

CREATE TYPE box (
    INTERNALLENGTH = 16,
    INPUT = my_box_in_function,
    OUTPUT = my_box_out_function,
    ELEMENT = float4
);

which would allow a box value's component numbers to be accessed by subscripting. Otherwise the type behaves the same as before. このようにすると、box値の要素に要素番号でアクセスできます。 その他は、上の例と同様の動作をします。

This example creates a large object type and uses it in a table definition: 次の例では、ラージオブジェクト型を作成し、テーブル定義にてそれを使用します。

CREATE TYPE bigobj (
    INPUT = lo_filein, OUTPUT = lo_fileout,
    INTERNALLENGTH = VARIABLE
);
CREATE TABLE big_objs (
    id integer,
    obj bigobj
);

More examples, including suitable input and output functions, are in <xref linkend="xtypes"/>. その他の例は、38.13を参照してください。ここには、入力関数、出力関数などを使った例があります。

互換性

<title>Compatibility</title>

The first form of the <command>CREATE TYPE</command> command, which creates a composite type, conforms to the <acronym>SQL</acronym> standard. The other forms are <productname>PostgreSQL</productname> extensions. The <command>CREATE TYPE</command> statement in the <acronym>SQL</acronym> standard also defines other forms that are not implemented in <productname>PostgreSQL</productname>. 複合型を作成する、最初のCREATE TYPEコマンドの構文は標準SQLに従います。 他の構文はPostgreSQLの拡張です。 標準SQLではまた他のCREATE TYPE構文を定義していますが、PostgreSQLでは実装されていません。

The ability to create a composite type with zero attributes is a <productname>PostgreSQL</productname>-specific deviation from the standard (analogous to the same case in <command>CREATE TABLE</command>). ゼロ個の要素を持つ複合型を作成する機能は標準から派生したPostgreSQL固有のもの(CREATE TABLEの場合と同様)です。

関連項目

<title>See Also</title> ALTER TYPE, CREATE DOMAIN, CREATE FUNCTION, DROP TYPE