Skip to content

Instantly share code, notes, and snippets.

@kwatch
Created April 28, 2014 02:13
Show Gist options
  • Save kwatch/11360274 to your computer and use it in GitHub Desktop.
Save kwatch/11360274 to your computer and use it in GitHub Desktop.
[Q] Is it possible to rename column1, column2, ... into arbitrary names in VALUES statement?
-- I want to rename column1 and column2 into id and name
psql=> values (101, 'Steve'), (102, 'Bill');
column1 | column2
---------+---------
101 | Steve
102 | Bill
(2 rows)
@kwatch
Copy link
Author

kwatch commented Apr 28, 2014

-- thanks to RhodiumToad!
psql=> select * from (values (101, 'Steve'), (102, 'Bill')) as tmp(id, name);
id | name
-----+-------
101 | Steve
102 | Bill
(2 rows)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment