Hi,
I would like to propose adding support for an alternative INSERT syntax that uses named column assignments via a SET clause. This provides a more convenient and readable way to write inserts, particularly when only specific columns need values.
Currently, PostgreSQL requires INSERT statements to separate the column list from the values:
INSERT INTO users (name, email, status) VALUES ('Alice', '
alice@example.com', 'active');
For inserts with many columns or where only a subset of columns are specified, the proposed SET syntax offers better readability by keeping column names adjacent to their values:
INSERT INTO users SET name='Alice', email='
alice@example.com', status='active';
Proposed Syntax:
INSERT INTO table_name
SET (column1=value1, column2=value2, ...), (, ...)
[ ON CONFLICT ... ]
[ RETURNING ... ];
Below INSERT features are supported:
- DEFAULT keyword: SET col=DEFAULT
- Expressions and functions: SET col=expr, col2=function(...)
- Subqueries: SET col=(SELECT ...)
- RETURNING clause
- ON CONFLICT DO UPDATE/NOTHING
- OVERRIDING SYSTEM VALUE
- Multi-row syntax: SET (col1=val1, col2=val2), (col1=val3, col2=val4)
Columns not mentioned receive their default values or NULL, consistent with standard INSERT behavior.
I've attached the patch. Looking forward to your feedback.