Run a PostgreSQL .sql file using command line arguments

前端 未结 12 1978
面向向阳花
面向向阳花 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:40

    Of course, you will get a fatal error for authenticating, because you do not include a user name...

    Try this one, it is OK for me :)

    psql -U username -d myDataBase -a -f myInsertFile
    

    If the database is remote, use the same command with host

    psql -h host -U username -d myDataBase -a -f myInsertFile
    

提交回复
热议问题