There is an old and deprecated command in PostgreSQL that predates CREATE TABLE AS SELECT
(CTAS) called SELECT ... INTO .... FROM
, it supports WITH
clauses / Common Table Expressions (CTE). So, for instance, I can do this..
WITH w AS ( SELECT * FROM ( VALUES (1) ) AS t(x))SELECT *INTO fooFROM w;
But, I can't do this..
WITH w AS ( SELECT * FROM ( VALUES (1) ) AS t(x))CREATE TABLE foo ASSELECT * FROM w;
Or, I get
ERROR: syntax error at or near "CREATE"LINE 5: CREATE TABLE foo AS
How would I do that using the standardized CTAS syntax.