PostgreSQL CSV import from command line

前端 未结 4 1782
予麋鹿
予麋鹿 2020-12-13 09:15

I\'ve been using the psql Postgres terminal to import CSV files into tables using the following

COPY tbname FROM
\'/tmp/the_file.csv\'
delimiter \'|\' csv;
<         


        
4条回答
  •  温柔的废话
    2020-12-13 09:36

    To complete the previous answer, I would suggest:

    psql -d your_dbname --user=db_username -c "COPY tbname FROM '/tmp/the_file.csv' delimiter '|' csv;"
    

提交回复
热议问题