Run a PostgreSQL .sql file using command line arguments

前端 未结 12 2010
面向向阳花
面向向阳花 2020-11-28 00:08

I have some .sql files with thousands of INSERT statements in them and need to run these inserts on my PostgreSQL database in order to add them to a table. The files are tha

12条回答
  •  旧时难觅i
    2020-11-28 00:37

    you could even do it in this way:

    sudo -u postgres psql -d myDataBase -a -f myInsertFile
    

    If you have sudo access on machine and it's not recommended for production scripts just for test on your own machine it's the easiest way.

提交回复
热议问题