// data type reference

Composite, table and object types

Define your own row shape once, use it as a column type, a function parameter, or a table of rows. PostgreSQL, SQL Server and Oracle each own a flavor; MySQL and SQLite have nothing to translate it into.

Missing in
MySQL, SQLite
Gotchas
5 listed

Engine by engine

Composite types bundle fields into one named type: PostgreSQL composites and Oracle OBJECTs become column types, SQL Server table types carry rows into procedures, and MySQL/SQLite simply lack them.

Composite & object types in SQL Server, PostgreSQL, MySQL, SQLite and Oracle: type name, storage and notes
Engine Typ Speicher Notizen
SQL Server CREATE TYPE ... AS TABLE Per definition Table types (table-valued parameters) pass rowsets into procedures; also CLR UDTs for scalar custom types. No composite column type.
PostgreSQL CREATE TYPE ... AS (...) Sum of fields Composite types: usable as column types, function return rows, and row constructors; every table and view also implicitly creates one.
MySQL none Workaround k.A. No composite or object types. Pack into JSON columns or normalize to child tables.
SQLite none Workaround k.A. No composite or object types; JSON in TEXT is the only bundling mechanism.
Oracle CREATE TYPE ... AS OBJECT Per definition Object types work as column types, as the row type of object tables (which carry an OID per row), in VARRAYs and nested tables, and as PL/SQL argument types.

Gotchas

Where the engines disagree. These tend to surface as bugs during a migration or a port.

  1. PostgreSQL composite columns resist change: ADD and DROP ATTRIBUTE work while a table uses the type, but ALTER ATTRIBUTE ... TYPE fails with 'cannot alter type because column uses it', and many ORMs cannot map a row inside a row.
  2. Oracle stores an object column as hidden scalar columns (one per attribute plus a null indicator), object tables add a 16-byte OID per row, and nested tables need a STORE AS clause. Loaders and drivers that expect plain columns need special handling.
  3. SQL Server table types are read-only in use: table-valued parameters flow in, they cannot be a column, and a type change requires dropping every procedure that references it first.
  4. Every engine with custom types ties the type to the schema lifecycle: you cannot drop a type that a column, function, or procedure uses, so 'just rename the field' becomes a migration.
  5. MySQL and SQLite translations are lossy by definition: a composite becomes either flattened columns (losing the one-value semantics) or a JSON blob (losing per-field typing).

Common questions

What is a table-valued parameter in SQL Server?

A CREATE TYPE ... AS TABLE definition used to pass a rowset into a stored procedure or batch as one parameter, declared READONLY. It is SQL Server's only structured user type, and it cannot be a column type.

Can a PostgreSQL column be of a row type?

Yes: CREATE TYPE address AS (city text, zip text); then a column address address stores the struct inline, queried as (col).city. Every table already has an implicit row type too, usable in functions.

How do I migrate Oracle OBJECT columns to PostgreSQL?

Flatten to scalar columns, or map to a PostgreSQL composite type (or JSONB for flexible shapes). Object-table OIDs, REF columns and storage clauses do not translate; plan the driver and ORM changes too.

// map types before you move data

Map a type to the other four engines

The free type converter maps a type from one engine to its closest equivalent in the others and says where storage, precision or behaviour differ. The desktop app does the same mapping while you edit.