Run a PostgreSQL .sql file using command line arguments

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

    You have four choices to supply a password:

    1. Set the PGPASSWORD environment variable. For details see the manual:
      http://www.postgresql.org/docs/current/static/libpq-envars.html
    2. Use a .pgpass file to store the password. For details see the manual:
      http://www.postgresql.org/docs/current/static/libpq-pgpass.html
    3. Use "trust authentication" for that specific user: http://www.postgresql.org/docs/current/static/auth-methods.html#AUTH-TRUST
    4. Since PostgreSQL 9.1 you can also use a connection string:
      https://www.postgresql.org/docs/current/static/libpq-connect.html#LIBPQ-CONNSTRING

提交回复
热议问题