Hacker News new | past | comments | ask | show | jobs | submit login

That COPY trick is really neat. I've always used SELECT INTO.

    SELECT *
    INTO TEMP copy
    FROM foobar;
    \copy "copy" to 'foobar.csv' with csv headers



I'm always looking for new copy tricks. Is "copy" a temporary table? Or a variable...?


Temporary table. Although looking at the docs it seems CREATE TABLE AS is the recommended syntax. https://www.postgresql.org/docs/13/sql-createtableas.html

    CREATE TEMP TABLE "copy" AS
    SELECT * FROM foobar;




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: