Re: How to execute the sql file in PSQL

From: Mark <jxustnc(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: How to execute the sql file in PSQL
Date: 2020-10-06 08:23:28
Message-ID: CALChJr7La+9bFEy5mXtd_SyOKzu762Hsukph0D9zMF6ssz8Rgw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Actually, a single quotation will work.

\ir 'C:\\Program Files\\PostgreSQL\\12\\demo-big-en-20170815.sql'

But I don't know why a single quotation will work.

It would be very helpful if you guys can explain to me.

On Mon, Oct 5, 2020 at 9:31 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> writes:
> > On 10/5/20 7:55 AM, Mark wrote:
> >> I followed one PostgreSQL tutorial step by step. One session to use
> PSQL
> >> to execute sql files to create a new database in PostgreSQL.
> >> 1. copy paste the sql file within "C:\Program Files\PostgreSQL\12"
> >> directory.
> >> 2. execute the following code \i C:\\Program
> >> Files\\PostgreSQL\\12\\demo-big-en-20170815.sql
> >>
> >> Failed
> >> The message shows C:: Permission denied
>
> > The issue is the user you are running psql as does not have permissions
> > to read the file. This is a OS permissions thing. Either run psql as a
> > user that can read the file or change the permissions on the file to
> > those that allow the psql user to read it.
>
> ... or more likely, put the SQL file in a saner place. Dropping random
> files into a program directory can only lead to trouble. You should
> treat such directories as read-only unless you know exactly what you
> are doing.
>
> It seems likely to me that this failure stems from PG being installed
> with permissions settings that prevent it from reading/modifying its own
> executables, which is good solid security practice.
>
> (If the tutorial actually told you to do that, the tutorial's author
> is utterly clueless.)
>
> regards, tom lane
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jayaram 2020-10-06 09:05:19 RE: Handling time series data with PostgreSQL
Previous Message Pankaj Jangid 2020-10-06 06:45:43 Re: How to update a table with the result of deleting rows in another table