Thread: Query from shell

Query from shell

From
Judith
Date:
      Hi every body, somebody can show me hot to execute a query from a 
shell
   thanks in advanced!!!



Re: Query from shell

From
"Owen Jacobson"
Date:
Judith wrote:

>        Hi every body, somebody can show me hot to execute a
> query from a shell

echo QUERY HERE | psql databasename

Or, if you want to run several queries, run psql and run your queries there.


Re: Query from shell

From
Bricklen Anderson
Date:
Owen Jacobson wrote:
> Judith wrote:
> 
> 
>>       Hi every body, somebody can show me hot to execute a 
>>query from a shell
> 
> 
> echo QUERY HERE | psql databasename
> 
> Or, if you want to run several queries, run psql and run your queries there.
> 
or
psql -d <dbname> -c "your query here"


Re: Query from shell

From
Terry Lee Tucker
Date:
On Thursday 06 April 2006 02:37 pm, Judith saith:
>        Hi every body, somebody can show me hot to execute a query from a
> shell
>
>     thanks in advanced!!!
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
>                http://archives.postgresql.org

Do this:
psql  -c 'SELECT code FROM cust' rnd;



Re: Query from shell

From
kevin.kempter@dataintellect.com
Date:
On Thursday 06 April 2006 15:37, Owen Jacobson wrote:
> Judith wrote:
> >        Hi every body, somebody can show me hot to execute a
> > query from a shell
>
> echo QUERY HERE | psql databasename
>
> Or, if you want to run several queries, run psql and run your queries
> there.
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster


I think you can also run:
psql -f filename.sql database_name


Re: Query from shell

From
"Jim Buttafuoco"
Date:
or

psql db <<EOQ
select...;
delete...;
update...;
\q
EOQ



---------- Original Message -----------
From: "Owen Jacobson" <ojacobson@osl.com>
To: <pgsql-sql@postgresql.org>
Sent: Thu, 6 Apr 2006 14:37:51 -0700
Subject: Re: [SQL] Query from shell

> Judith wrote:
> 
> >        Hi every body, somebody can show me hot to execute a 
> > query from a shell
> 
> echo QUERY HERE | psql databasename
> 
> Or, if you want to run several queries, run psql and run your queries there.
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster
------- End of Original Message -------