Composite type (table.*)
PG 7.4+→ set of all fieldsExpands all columns of a table row as individual fields. Useful in SELECT, INSERT, and with composite types.
Signature
table.* → expanded row fieldsParameters
| Parameter | Type | Description |
|---|---|---|
| table_ref | table or composite value | Source to expand |
Examples
SELECT u.* FROM users u WHERE id = 1;All columns of user rowSELECT (ROW(1, 'Alice', true)).* AS (id int, name text, active bool);Expanded composite record fieldsSELECT json_populate_record(NULL::users, data).* FROM user_json_queue;Expanded typed record from JSONSELECT (p).*, row_number() OVER (PARTITION BY (p).category ORDER BY (p).price) AS rank
FROM (SELECT product_row AS p FROM product_catalog) sub;All product fields plus a per-category price rank, expanding a composite column inlineWhen `SELECT t.*` order and the INSERT target column order differ (which can happen silently after an ALTER TABLE ADD COLUMN or if tables were created independently), values land in the wrong columns with no error raised.
✓ Instead: Always name columns explicitly in INSERT: `INSERT INTO target (col1, col2) SELECT col1, col2 FROM source` rather than relying on positional `SELECT *` expansion.
Chain `json_populate_record(NULL::target_type, json_col).*` to convert a JSON column into typed columns in one step — a clean pattern for importing JSON payloads into a staging table.
INSERT INTO users SELECT (json_populate_record(NULL::users, payload)).* FROM user_import_queue;Typed insert from JSON payload