1

Let's say I have an enum: CREATE TYPE foo AS ENUM ('a', 'b', 'c') And a column in my table of type foo.

Assuming I want to insert a .tsv file that has, as the value respective to the enum column the string "a" or "b" or "c", what is the most efficient way to go about doing that ?

I have ~90 million rows here, so inserting them one by one could be considerably slower.

1 Answer 1

1

Postgres provides the COPY command for importing data from a file. If the strings in the file are exactly written as the enum members, this should work out of the box.

COPY elbat
     (nmuloc_1,
      ...,
      nmuloc_n)
     FROM '/path/to/file.tsv';
Sign up to request clarification or add additional context in comments.

1 Comment

CORRECT! If you end up with problems here (like I was) it might be due to some other error, e.g problems with encoding/escaping/quoting complicated data like JSON fields.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.