Home Explore Blog CI



postgresql

33th chunk of `doc/src/sgml/information_schema.sgml`
b5c5ecc28cf778d6a90772e364ff2e56eb1a8ec86fef01110000000100000fa6
 only contains one data type
       descriptor).  This is mainly useful for joining with other
       instances of such identifiers.  (The specific format of the
       identifier is not defined and not guaranteed to remain the same
       in future versions.)
      </para></entry>
     </row>
    </tbody>
   </tgroup>
  </table>
 </sect1>

 <sect1 id="infoschema-element-types">
  <title><literal>element_types</literal></title>

  <para>
   The view <literal>element_types</literal> contains the data type
   descriptors of the elements of arrays.  When a table column, composite-type attribute,
   domain, function parameter, or function return value is defined to
   be of an array type, the respective information schema view only
   contains <literal>ARRAY</literal> in the column
   <literal>data_type</literal>.  To obtain information on the element
   type of the array, you can join the respective view with this view.
   For example, to show the columns of a table with data types and
   array element types, if applicable, you could do:
<programlisting>
SELECT c.column_name, c.data_type, e.data_type AS element_type
FROM information_schema.columns c LEFT JOIN information_schema.element_types e
     ON ((c.table_catalog, c.table_schema, c.table_name, 'TABLE', c.dtd_identifier)
       = (e.object_catalog, e.object_schema, e.object_name, e.object_type, e.collection_type_identifier))
WHERE c.table_schema = '...' AND c.table_name = '...'
ORDER BY c.ordinal_position;
</programlisting>
   This view only includes objects that the current user has access
   to, by way of being the owner or having some privilege.
  </para>

  <table>
   <title><structname>element_types</structname> Columns</title>
   <tgroup cols="1">
    <thead>
     <row>
      <entry role="catalog_table_entry"><para role="column_definition">
       Column Type
      </para>
      <para>
       Description
      </para></entry>
     </row>
    </thead>

    <tbody>
     <row>
      <entry role="catalog_table_entry"><para role="column_definition">
       <structfield>object_catalog</structfield> <type>sql_identifier</type>
      </para>
      <para>
       Name of the database that contains the object that uses the
       array being described (always the current database)
      </para></entry>
     </row>

     <row>
      <entry role="catalog_table_entry"><para role="column_definition">
       <structfield>object_schema</structfield> <type>sql_identifier</type>
      </para>
      <para>
       Name of the schema that contains the object that uses the array
       being described
      </para></entry>
     </row>

     <row>
      <entry role="catalog_table_entry"><para role="column_definition">
       <structfield>object_name</structfield> <type>sql_identifier</type>
      </para>
      <para>
       Name of the object that uses the array being described
      </para></entry>
     </row>

     <row>
      <entry role="catalog_table_entry"><para role="column_definition">
       <structfield>object_type</structfield> <type>character_data</type>
      </para>
      <para>
       The type of the object that uses the array being described: one
       of <literal>TABLE</literal> (the array is used by a column of
       that table), <literal>USER-DEFINED TYPE</literal> (the array is
       used by an attribute of that composite type),
       <literal>DOMAIN</literal> (the array is used by that domain),
       <literal>ROUTINE</literal> (the array is used by a parameter or
       the return data type of that function).
      </para></entry>
     </row>

     <row>
      <entry role="catalog_table_entry"><para role="column_definition">
       <structfield>collection_type_identifier</structfield> <type>sql_identifier</type>
      </para>
      <para>
       The identifier of the data type descriptor of the array being
       described.  Use this to join with the
       <literal>dtd_identifier</literal> columns of other information
       schema views.
      </para></entry>
     </row>

Title: Information Schema: Element Types View
Summary
The element_types view in the information schema contains data type descriptors of array elements, allowing users to join with other views to obtain information on element types, and includes columns for object catalog, schema, name, type, and collection type identifier, with examples of usage provided.