How to load data from a text file in a PostgreSQL database?

后端 未结 4 853
無奈伤痛
無奈伤痛 2020-12-14 17:06

I have a file like (CSV file):

value1|value2|value2....

value1|value2|value2....

value1|value2|value2....

value1|value2|value2....

and w

4条回答
  •  心在旅途
    2020-12-14 17:25

    Let consider that your data are in the file values.txt and that you want to import them in the database table myTable then the following query does the job

    COPY myTable FROM 'value.txt' (DELIMITER('|'));
    

    https://www.postgresql.org/docs/current/static/sql-copy.html

提交回复
热议问题