3

I have a csv file with 19 columns. How can I import the file to PostgreSQL without first creating a table and writing every column down? Thanks!

Jade Young
  • 99
  • 1
  • 7
  • 1
    You can't. A table needs to exist with the correct columns before you can import the CSV. – Adrian Klaver Jan 28 '22 at 20:42
  • you can do it using csvsql, it will create the table and import data, take a look at : https://stackoverflow.com/questions/21018256/can-i-automatically-create-a-table-in-postgresql-from-a-csv-file-with-headers – mshabou Jan 28 '22 at 20:55
  • How people handle .csv file with 30+ or even more columns then. I know this can be done in Bigquery but I cannot save and download queries as a sql file. How about MySQL? – Jade Young Jan 28 '22 at 20:59
  • A SQL database is table based and you need one to exist to import data into. Now there are tools that will help you with this, but in the end they do the same thing create a table then import the data. – Adrian Klaver Jan 28 '22 at 21:19

0 Answers0