Insert csv file of input data with COPY statement of postgresql,
I want to output only the data inserted immediately before.

[I am in trouble]
Select * FROM table name, not all data, only data inserted by COPY statement
I'm in trouble. . .
I want to select only the second and third rows of the table listed below. (Can it be done with a COPY statement?)
I'm sorry for ignorance, but it will be helpful if I get wisdom.

test1 INT4 NOT NULL,
test2 INT4 NOT NULL,
test3 VARCHAR (256));
\ copy testDB (test1, test2, test3) FROM '/tmp/inputCSV/test.csv' WITH CSV;
# I want to select the data inserted above.
select ~

● CSV content

● Contents of the table
ID | test1 | test2 | test3
1 1 1 1.jpg
2 2 2 2.jpg
3 3 3 3.jpg

  • Answer # 1

    It is difficult to identify with the information in the data in the question.

    If you only want to identify it temporarily, it would be quickest to import the CSV into another table.
    If constant identification is required, information that can be identified is necessary.

    If you add a

    column and set a value for that item if it is not based on COPY, it will be NULL for COPY.

    In the opposite case, CSV is imported into a temporary table by COPY, and identification information is also set when updating from that table to the target table.