Skip to content

Instantly share code, notes, and snippets.

@yancya
Created February 14, 2018 15:16
Show Gist options
  • Save yancya/6bda42d28bdd43f7e241c462831e3552 to your computer and use it in GitHub Desktop.
Save yancya/6bda42d28bdd43f7e241c462831e3552 to your computer and use it in GitHub Desktop.
CREATE TEMP TABLE hoge (id integer, name text);
WITH t(id, name) AS (VALUES (1, 'hoge'), (2, 'fuga'), (3, 'piyo'))
, t2 AS (INSERT INTO hoge SELECT id, name FROM t)
INSERT INTO hoge SELECT id * 10, name FROM t;
SELECT * FROM hoge;
-- id | name
-- ----+------
-- 10 | hoge
-- 20 | fuga
-- 30 | piyo
-- 1 | hoge
-- 2 | fuga
-- 3 | piyo
-- (6 rows)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment