Home Explore Blog CI



postgresql

8th chunk of `doc/src/sgml/ref/create_type.sgml`
9cfa1a2ee43d820cb2bd1e52bdfa7ee75656be93867ed0780000000100000fab
 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>.
  </para>

  <para>
   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.
  </para>

  <para>
   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.
  </para>

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

  <para>
   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.
  </para>

  <para>
   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.
  </para>

  <para>
   If the optional Boolean
   parameter <replaceable class="parameter">collatable</replaceable>
   is true, column definitions

Title: CREATE TYPE - Additional Options: TOAST, LIKE, Category, Preferred, Default, Element, Delimiter, and Collatable
Summary
This section details additional options for `CREATE TYPE`, including how it interacts with TOAST for storage management, the LIKE parameter for copying representation properties, category and preferred parameters for controlling implicit casts, specifying default values, defining array types with the ELEMENT keyword, setting array delimiters, and the collatable parameter for column definitions.