Обсуждение: Running sql files

Поиск
Список
Период
Сортировка

Running sql files

От
"Pradeepkumar, Pyatalo (IE10)"
Дата:

Hi,

I just wanted to know how to disable the results being displayed on the screen.
When I try the following command -
$psql dbname < sqlfile
The results of  the command are displayed on to the screen. In one file I am trying to populate a table with values ( There are more than 5000 tuples to be inserted).

When I run this command, it displays the results on to the screen which I don't want to do.
Could anyone help me in this.

Thanks in advance.

Regards,
Pradeep

Re: Running sql files

От
"Kevin Izzet"
Дата:

Hi,

You could try running the command like this

$psql dbname < sqlfile > /dev/null

I believe this  should work fine





Regards

Kevin Izzet

Database / Unix / Linux  Administrator
Tel:     (Code)+44(0)1475 655606
Fax:    (Code)+44(0)1475 637755
Email:  Kevin.Izzet@nsc.com



"Pradeepkumar, Pyatalo (IE10)" <Pradeepkumar.Pyatalo@honeywell.com>
Sent by: pgsql-admin-owner@postgresql.org

07/12/2004 11:55

       
        To:        pgsql-admin@postgresql.org
        cc:        
        Subject:        [ADMIN] Running sql files



Hi,

I just wanted to know how to disable the results being displayed on the screen.
When I try the following command -
$psql dbname < sqlfile

The results of  the command are displayed on to the screen. In one file I am trying to populate a table with values ( There are more than 5000 tuples to be inserted).

When I run this command, it displays the results on to the screen which I don't want to do.
Could anyone help me in this.

Thanks in advance.

Regards,
Pradeep

Re: Running sql files

От
"Pradeepkumar, Pyatalo (IE10)"
Дата:
Hi all,

Thanks a lot for all your valuable inputs. I tried "\set QUIET" and "\unset
QUIET" arount certain parts of the file. It works fine with INSERT COMMANDS.
But incase of creating tables, it still prints NOTICE and ERROR messages on
the screen...how do I restrict that.

Regs,
Pradeep


-----Original Message-----
From: Michael Fuhr [mailto:mike@fuhr.org]
Sent: Tuesday, December 07, 2004 10:32 PM
To: Pradeepkumar, Pyatalo (IE10)
Cc: pgsql-admin@postgresql.org
Subject: Re: [ADMIN] Running sql files

On Tue, Dec 07, 2004 at 04:55:24AM -0700, Pradeepkumar, Pyatalo (IE10)
wrote:

> $psql dbname < sqlfile
> The results of  the command are displayed on to the screen. In one
> file I am trying to populate a table with values ( There are more than
> 5000 tuples to be inserted).
> When I run this command, it displays the results on to the screen
> which I don't want to do.

As someone else suggested, you could redirect the script's output to
/dev/null.  You could also use psql's -q ("quiet") option or surround
certain parts of the file with "\set QUIET" and "\unset QUIET".

COPY is quieter and more efficient than INSERT, so if you're using INSERT
then you could replace it with the appropriate COPY statement.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

Re: Running sql files

От
John DeSoi
Дата:
On Dec 7, 2004, at 6:55 AM, Pradeepkumar, Pyatalo (IE10) wrote:

> I just wanted to know how to disable the results being displayed on
> the screen.
> When I try the following command -
> $psql dbname < sqlfile
> The results of  the command are displayed on to the screen. In one
> file I am trying to populate a table with values ( There are more than
> 5000 tuples to be inserted).
>
> When I run this command, it displays the results on to the screen
> which I don't want to do.
> Could anyone help me in this.

You can also send the output to a file with the -o option. That way,
you can review the results if any problems arise.

$psql -o myoutput dbname < sqlfile

See the psql section in the manual for more options to control the
output.

Best,

John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL



Re: Running sql files

От
Michael Fuhr
Дата:
On Tue, Dec 07, 2004 at 10:23:44PM -0700, Pradeepkumar, Pyatalo (IE10) wrote:

> Thanks a lot for all your valuable inputs. I tried "\set QUIET" and "\unset
> QUIET" arount certain parts of the file. It works fine with INSERT COMMANDS.
> But incase of creating tables, it still prints NOTICE and ERROR messages on
> the screen...how do I restrict that.

You could SET the client_min_messages variable.  See the documentation
for the SET command and the "Run-time Configuration" section in the
"Server Run-time Environment" chapter.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

Re: Running sql files

От
Michael Fuhr
Дата:
On Tue, Dec 07, 2004 at 04:55:24AM -0700, Pradeepkumar, Pyatalo (IE10) wrote:

> $psql dbname < sqlfile
> The results of  the command are displayed on to the screen. In one file I am
> trying to populate a table with values ( There are more than 5000 tuples to
> be inserted).
> When I run this command, it displays the results on to the screen which I
> don't want to do.

As someone else suggested, you could redirect the script's output
to /dev/null.  You could also use psql's -q ("quiet") option or
surround certain parts of the file with "\set QUIET" and "\unset
QUIET".

COPY is quieter and more efficient than INSERT, so if you're using
INSERT then you could replace it with the appropriate COPY statement.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

Re: Running sql files

От
Jaime Casanova
Дата:
 --- "Pradeepkumar, Pyatalo (IE10)"
<Pradeepkumar.Pyatalo@honeywell.com> escribió:
>
> Hi,
>
> I just wanted to know how to disable the results
> being displayed on the
> screen.
> When I try the following command -
> $psql dbname < sqlfile
> The results of  the command are displayed on to the
> screen. In one file I am
> trying to populate a table with values ( There are
> more than 5000 tuples to
> be inserted).
> When I run this command, it displays the results on
> to the screen which I
> don't want to do.
> Could anyone help me in this.
>

$psql dbname < sqlfile > /dev/null

regards,
Jaime Casanova

_________________________________________________________
Do You Yahoo!?
Información de Estados Unidos y América Latina, en Yahoo! Noticias.
Visítanos en http://noticias.espanol.yahoo.com