-3

My Data is having more than 200 columns, So how can I import it into my database without writing queries?

Adrian Klaver
  • 15,886
  • 2
  • 17
  • 28
  • I am using 13.1 – OmTheAnalyst Sep 02 '21 at 21:37
  • 1
    Then don't include tags for versions that you are not using. I went ahead and removed them. – Adrian Klaver Sep 02 '21 at 23:19
  • This is going to need more information: 1) Where is the data now? 2) How large a data set is it? 3) Do you want to have a 200 column table? Add the answers as updates to your question. – Adrian Klaver Sep 02 '21 at 23:21
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Sep 06 '21 at 14:45

1 Answers1

0

I would try using a CSV. This is the way I move most data between different database formats and also importing data from sources other than SQL databases.

The lowest limit on column counts in a CSV that I know of is 255 columns but many programs can export CSV's with much more than that. PgAdmin imports CSV's very easily in most cases. PgAdmin's limit is 1600 columns.

Navigate to the table, right-click and select "Import/Export" and follow the instructions in the dialogue and in most cases it will work well. You may need to clean the data first, check column types. With that many columns that could be a huge amount of work, but this approach is not likely to be more difficult than most.

If you don't already have a table matching the structure of the data, you will need to create it first.

If you want to auto-create the table, which might be a good idea with that many columns, I suggest checking out this answer:

Can I automatically create a table in PostgreSQL from a csv file with headers?

You may find the solution by Wolfi useful; it uses a tool called pgfutter, but there are other solutions too.

cazort
  • 516
  • 6
  • 19