Run a PostgreSQL .sql file using command line arguments

前端 未结 12 1982
面向向阳花
面向向阳花 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条回答
  •  一生所求
    2020-11-28 00:32

    If you are logged in into psql on the Linux shell the command is:

    \i fileName.sql
    

    for an absolute path and

    \ir filename.sql
    

    for the relative path from where you have called psql.

提交回复
热议问题