pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedSQL statement form shell ?
7+ messages / 3 participants
[nested] [flat]
* SQL statement form shell ?
@ 2014-08-27 15:04 czezz <czezz@o2.pl>
0 siblings, 2 replies; 7+ messages in thread
From: czezz @ 2014-08-27 15:04 UTC (permalink / raw)
To: pgsql-admin
Im trying to execute simple query in shell.
This query works OK in PSQL client:
Server4=# SELECT * FROM foo2;
However, for some reason I cannot execute it in shell. I try it like following:
-bash-4.1$ psql -p 5472 -d fm_db_Server4 -c "SELECT * FROM foo2;"
ERROR: relation "foo2" does not exist
LINE 1: SELECT * FROM foo2;
^
Any ideas what Im doing wrong ?
BR,
czezz
--
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: SQL statement form shell ?
@ 2014-08-27 15:13 Raghavendra <raghavendra.rao@enterprisedb.com>
parent: czezz <czezz@o2.pl>
1 sibling, 1 reply; 7+ messages in thread
From: Raghavendra @ 2014-08-27 15:13 UTC (permalink / raw)
To: czezz <czezz@o2.pl>; +Cc: pgsql-admin
Is the database name correct ?
In your OK execution, database looks to be "Server4" and in other execution
its "fm_db_Server4".
---
Regards,
Raghavendra
EnterpriseDB Corporation
Blog: http://raghavt.blogspot.com/
On Wed, Aug 27, 2014 at 8:34 PM, czezz <czezz@o2.pl> wrote:
> Im trying to execute simple query in shell.
> This query works OK in PSQL client:
> Server4=# SELECT * FROM foo2;
>
> However, for some reason I cannot execute it in shell. I try it like
> following:
>
> -bash-4.1$ psql -p 5472 -d fm_db_Server4 -c "SELECT * FROM foo2;"
> ERROR: relation "foo2" does not exist
> LINE 1: SELECT * FROM foo2;
> ^
>
> Any ideas what Im doing wrong ?
>
> BR,
> czezz
>
>
> --
> Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-admin
>
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: SQL statement form shell ?
@ 2014-08-27 15:23 czezz <czezz@o2.pl>
parent: Raghavendra <raghavendra.rao@enterprisedb.com>
0 siblings, 1 reply; 7+ messages in thread
From: czezz @ 2014-08-27 15:23 UTC (permalink / raw)
To: Raghavendra <raghavendra.rao@enterprisedb.com>; +Cc: pgsql-admin
Copy/Paste error. DB name should be: fm_db_Server4
Dnia 27 sierpnia 2014 17:13 Raghavendra <raghavendra.rao@enterprisedb.com> napisał(a):
fm_db_Server4
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: SQL statement form shell ?
@ 2014-08-27 15:30 Scott Whitney <scott@journyx.com>
parent: czezz <czezz@o2.pl>
1 sibling, 1 reply; 7+ messages in thread
From: Scott Whitney @ 2014-08-27 15:30 UTC (permalink / raw)
To: czezz <czezz@o2.pl>; +Cc: pgsql-admin
There are a few things I would check.
a) psql -p 5472 -d fm_db_Server4
b) SELECT * from foo2;
c) Do those _2_ statements work separately? That should prove that you're talking to the exact same connection/host/port you expect.
d) psql -p 5472 -d fm_db_Server4 -c "SELECT * FROM foo2;
So, step a&b succeed, but step d fails?
d) psql -p 5472 -d fm_db_Server4
e) SELECT * from "foo2";
If this doesn't work, "foo2," is not a valid relation. It's case-sensitive or some such. Once you can make the table name work within " " marks, THEN try from the command prompt like:
f) psql -p 5472 -d fm_db_Server4 -c "SELECT * FROM \"foo2\" ; "
----- Original Message -----
> Im trying to execute simple query in shell.
> This query works OK in PSQL client:
> Server4=# SELECT * FROM foo2;
> However, for some reason I cannot execute it in shell. I try it like
> following:
> -bash-4.1$ psql -p 5472 -d fm_db_Server4 -c "SELECT * FROM foo2;"
> ERROR: relation "foo2" does not exist
> LINE 1: SELECT * FROM foo2;
> ^
> Any ideas what Im doing wrong ?
> BR,
> czezz
> --
> Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-admin
Journyx, Inc.
7600 Burnet Road #300
Austin, TX 78757
www.journyx.com
p 512.834.8888
f 512.834.8858
Do you receive our promotional emails? You can subscribe or unsubscribe to those emails at http://go.journyx.com/emailPreference/e/4932/714
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: SQL statement form shell ?
@ 2014-08-27 16:43 Raghavendra <raghavendra.rao@enterprisedb.com>
parent: czezz <czezz@o2.pl>
0 siblings, 1 reply; 7+ messages in thread
From: Raghavendra @ 2014-08-27 16:43 UTC (permalink / raw)
To: czezz <czezz@o2.pl>; +Cc: pgsql-admin
On Wed, Aug 27, 2014 at 8:53 PM, czezz <czezz@o2.pl> wrote:
> Copy/Paste error. DB name should be: fm_db_Server4
>
>
>
Did you set
PGOPTIONS environment variable for that terminal for any specific schema
which do not contain the table "foo"
. Then you might hit the error
-bash-4.1$ export PGOPTIONS="-c search_path=tester"
-bash-4.1$ psql -p 5432 -d postgres -c "SELECT * FROM foo;"
ERROR: relation "foo" does not exist
LINE 1: SELECT * FROM foo;
^
---
Regards,
Raghavendra
EnterpriseDB Corporation
Blog: http://raghavt.blogspot.com/
>
> Dnia 27 sierpnia 2014 17:13 Raghavendra <raghavendra.rao@enterprisedb.com>
> napisał(a):
>
> fm_db_Server4
>
>
>
>
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: SQL statement form shell ?
@ 2014-08-27 16:50 Scott Whitney <scott@journyx.com>
parent: Raghavendra <raghavendra.rao@enterprisedb.com>
0 siblings, 0 replies; 7+ messages in thread
From: Scott Whitney @ 2014-08-27 16:50 UTC (permalink / raw)
To: Raghavendra <raghavendra.rao@enterprisedb.com>; +Cc: czezz <czezz@o2.pl>; pgsql-admin
Also, throughout this thread, you have given us 2 separate ports: 5472 and 5432 (default).
In _this_ example, you set the database to "postgres," not to "Server4," as well.
Then there's that whole "foo," versus "foo2," thing going on...
There are a lot of differences in what you have sent over the course of this thread.
I would back up, take a deep breath, and start over.
1) Connect to your database something like this:
psql ___name of database___
2) SELECT * from "foo2";
3) Does that work? Once you make that work, proceed to test from the command line like this:
psql ___name of database__ -c "SELECT * from \"foo2\" ; "
If you make 1 and 2 work, 3 should work. BUT ALL OF THE OPTIONS HAVE TO BE THE SAME.
You cannot select * from foo in steps 1 and 2 and select * from foo2 in step 3.
You cannot use port 5472 in step 1/2 and 5432 in step 3.
You cannot connect to the db postgres in steps 1/2 and another db in step 3.
That invalidates your process.
----- Original Message -----
> On Wed, Aug 27, 2014 at 8:53 PM, czezz < czezz@o2.pl > wrote:
> > Copy/Paste error. DB name should be: fm_db_Server4
>
>
> Did you set
> PGOPTIONS environment variable for that terminal for any specific schema
> which do not contain the table "foo"
> . Then you might hit the error
> -bash-4.1$ export PGOPTIONS="-c search_path=tester"
> -bash-4.1$ psql -p 5432 -d postgres -c "SELECT * FROM foo;"
> ERROR: relation "foo" does not exist
> LINE 1: SELECT * FROM foo;
> ^
>
> ---
> Regards,
> Raghavendra
> EnterpriseDB Corporation
> Blog: http://raghavt.blogspot.com/
> > Dnia 27 sierpnia 2014 17:13 Raghavendra < raghavendra.rao@enterprisedb.com
> > >
> > napisał(a):
>
> > > fm_db_Server4
> >
>
Journyx, Inc.
7600 Burnet Road #300
Austin, TX 78757
www.journyx.com
p 512.834.8888
f 512.834.8858
Do you receive our promotional emails? You can subscribe or unsubscribe to those emails at http://go.journyx.com/emailPreference/e/4932/714
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: SQL statement form shell ?
@ 2014-08-28 08:19 czezz <czezz@o2.pl>
parent: Scott Whitney <scott@journyx.com>
0 siblings, 0 replies; 7+ messages in thread
From: czezz @ 2014-08-28 08:19 UTC (permalink / raw)
To: Scott Whitney <swhitney@journyx.com>; Scott Whitney <scott@journyx.com>; +Cc: pgsql-admin; raghavendra.rao@enterprisedb.com; payal@omniti.co
Hi,
I think I got it.
It seems that I need to indicate specific user name and only then the query works.
-bash-4.1$ psql -p 5472 -d fm_db_Server4 -U msuper -c "SELECT * FROM foo2;"
Im new to postgresql but I guess -U (user) also somehow defines tablespace where specific table is created.
Anyway, thank you all for your help and answers.
Cheers,
czezz
Dnia 27 sierpnia 2014 17:30 Scott Whitney <scott@journyx.com> napisał(a):
There are a few things I would check. a) psql -p 5472 -d fm_db_Server4b) SELECT * from foo2;c) Do those _2_ statements work separately? That should prove that you're talking to the exact same connection/host/port you expect.d) psql -p 5472 -d fm_db_Server4 -c "SELECT * FROM foo2; So, step a&b succeed, but step d fails? d) psql -p 5472 -d fm_db_Server4e) SELECT * from "foo2";
If this doesn't work, "foo2," is not a valid relation. It's case-sensitive or some such. Once you can make the table name work within " " marks, THEN try from the command prompt like: f) psql -p 5472 -d fm_db_Server4 -c "SELECT * FROM \"foo2\" ; " Im trying to execute simple query in shell.
This query works OK in PSQL client:
Server4=# SELECT * FROM foo2;
However, for some reason I cannot execute it in shell. I try it like following:
-bash-4.1$ psql -p 5472 -d fm_db_Server4 -c "SELECT * FROM foo2;"
ERROR: relation "foo2" does not exist
LINE 1: SELECT * FROM foo2;
^
Any ideas what Im doing wrong ?
BR,
czezz
--
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin
Journyx, Inc.7600 Burnet Road #300
Austin, TX 78757
www.journyx.com p 512.834.8888 f 512-834-8858 Do you receive our promotional emails? You can subscribe or unsubscribe to those emails here.
^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2014-08-28 08:19 UTC | newest]
Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2014-08-27 15:04 SQL statement form shell ? czezz <czezz@o2.pl>
2014-08-27 15:13 ` Raghavendra <raghavendra.rao@enterprisedb.com>
2014-08-27 15:23 ` czezz <czezz@o2.pl>
2014-08-27 16:43 ` Raghavendra <raghavendra.rao@enterprisedb.com>
2014-08-27 16:50 ` Scott Whitney <scott@journyx.com>
2014-08-27 15:30 ` Scott Whitney <scott@journyx.com>
2014-08-28 08:19 ` czezz <czezz@o2.pl>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox