Skip to content

Instantly share code, notes, and snippets.

@ks-t0

ks-t0/insert.sql Secret

Last active December 23, 2021 02:48
Embed
What would you like to do?
\set file_path '/home/user/sql/'
\set sq '\''
\set file :sq:file_path:file_name:sq
\set command '\\copy tmp from ' :file ' delimiter ':sq',':sq ' csv header;'
create temp table tmp (
aaa integer
, bbb varchar
, ccc varchar
);
:command
INSERT INTO test_table (
aaa
, bbb
, ccc
, create_datetime
, update_datetime
)
SELECT
tmp.aaa
, tmp.bbb
, tmp.ccc
, current_timestamp
, current_timestamp
FROM tmp;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment