Flowdock
column_definitions(table_name) private

Returns the list of a table’s column names, data types, and default values.

The underlying query is roughly:

 SELECT column.name, column.type, default.value
   FROM column LEFT JOIN default
     ON column.table_id = default.table_id
    AND column.num = default.column_num
  WHERE column.table_id = get_table_id('table_name')
    AND column.num > 0
    AND NOT column.is_dropped
  ORDER BY column.num

If the table name is not prefixed with a schema, the database will take the first match from the schema search path.

Query implementation notes:

 - format_type includes the column size constraint, e.g. varchar(50)
 - ::regclass is a function that gives the id for a table name
Show source
Register or log in to add new notes.