Home > Enterprise >  Loading Data into the postgreSQL DB
Loading Data into the postgreSQL DB

Time:10-23

I have a '|' delimited txt file which has over a million records along with column names as the first entry. How to load this file into PostgreSQL DB?

Should I create a new empty table structure with column names before the import or directly import the csv file? What steps do I need to follow?

My current database is fairly new & empty, with no table as such as of now. Also, I do not have administrator access as well.

CodePudding user response:

  1. You should create a table with yourTableName with columns and types specified.
  2. Then you could use copy sql COPY yourTableName FROM 'value.txt' (DELIMITER('|'));

CodePudding user response:

You'll need to create the table first, be careful about the datatypes, if one is wrong then you'll get an error when loading the file.

After you've created the table you can use the COPY statement to load the file into your table

  • Related