PostgreSQL supports CREATE TABLE AS SELECT (CTAS). It also supports composite types that can represent whole rows.
Here is an example of a CTAS,
CREATE TABLE foo AS
SELECT * FROM ( VALUES (1), (2) );
Here is a few examples of SELECT
ing a row.
SELECT (1,2);
SELECT ROW(1,2);
SELECT t FROM ( VALUES (1,2), (2,100) ) AS t;
SELECT x FROM ( VALUES ((1,2)), ((2,100)) ) AS f(x);
SELECT (x,y) FROM ( VALUES (1,2), (2,100) ) AS t(x,y);
However, none of them seem to work with CTAS.
CREATE TABLE foo AS SELECT f FROM ( VALUES (1,2), (2,100) ) AS f(x,y);
ERROR: column "f" has pseudo-type record
CREATE TABLE foo AS SELECT (x,y) FROM ( VALUES (1,2), (2,100) ) AS f(x,y);
ERROR: column "row" has pseudo-type record
I get that this is a typing-error, but what syntax does CTAS want?