liveBook · Manning

Select * replace

As explained in DuckDB in Action

SELECT * REPLACE is a DuckDB SQL projection syntax that selects all columns while replacing specified column expressions or values.

SELECT * REPLACE keeps every column in a relation while substituting selected columns with new expressions. It is useful when a wide table or view needs one focused transformation without rewriting the entire projection. section 1.2 section 3.5.1

Write one or more replacement pairs as an expression followed by AS and the existing column name. The remaining columns stay selected, preserving the convenience of the star while making the changed field explicit. section 3.5.1

Round one column in a view

A power view exposes fractional kWh values. Replace only that presentation with an integer while retaining system_id and day: SELECT * REPLACE (round(kWh)::int AS kWh) FROM v_power_per_day; The result contains system_id, day, and integer kWh values, with 1,587 rows shown in the example output. section 3.5.1

How DuckDB in Action covers it

How deep it goes
Defines replacement pairs and demonstrates a rounded view column, while leaving broader projection details to related SELECT features.
Examples
Demonstrates rounding kWh in v_power_per_day and inspecting the resulting system_id, day, and kWh columns.
What you can do after
Apply it via DuckDB SQL to reshape one or more columns while retaining the rest of a relation.
How it connects
Connects SELECT *, SELECT * EXCLUDE, views, SQL projections, and data preparation.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of DuckDB in Action. The section links point to the parts of the book it draws on.