What if you could skip creating tables just to try out a few rows of data instantly?
Why VALUES clause for inline data in PostgreSQL? - Purpose & Use Cases
Imagine you want to quickly test or use a small set of data without creating a full table. You try writing each row manually in separate INSERT statements or creating temporary tables just for a few values.
This manual way is slow and clunky. Writing many INSERTs takes time, and creating temporary tables for tiny data feels like overkill. It's easy to make mistakes and hard to keep your code clean and readable.
The VALUES clause lets you list rows of data right inside your query. It's like writing a mini table on the spot. This makes testing, joining, or using small data sets fast and simple without extra setup.
INSERT INTO temp_table (id, name) VALUES (1, 'Alice'); INSERT INTO temp_table (id, name) VALUES (2, 'Bob');
VALUES (1, 'Alice'), (2, 'Bob')
You can quickly create and use small data sets inline, making your queries simpler and faster to write and understand.
When you want to test a query with example data or join a few values without creating a table, the VALUES clause lets you do it instantly inside your SELECT statement.
Manual data entry is slow and error-prone.
VALUES clause lets you write inline data rows easily.
This makes testing and small data use fast and clean.