Re: existence of user

From: Stephen Ingram <ingram(at)samsix(dot)com>
To: "Annie Bai" <annie_job(at)hotmail(dot)com>, pgsql-novice(at)postgresql(dot)org
Subject: Re: existence of user
Date: 2002-02-03 01:48:39
Message-ID: 20020203015417.THKH9269.femail7.sdc1.sfba.home.com@there
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Saturday 02 February 2002 08:37 pm, Annie Bai wrote:
> Hi Steve,
>
> I tried the command as you did
> %psql -c "select * from pg_user"
>
> but I got an error as 'Database ""select * from pg_user"" does not exist in
> the system catalog. Previous connection kept'.
>
> Need I change some configurations?
>

Hi Annie,

I suspect your PGDATABASE environment variable is not set.

You have two choices (at least)

a) set it :)

b) use the -d flag on psql (to stipulate a database), because
by default I guess it is looking at oe of the template databases.

Oh,

c) both :)

Here are some examples

si(at)guinness > echo $PGDATABASE
bugdb

si(at)guinness > psql -c "select * from pg_user"
usename | usesysid | usecreatedb | usetrace | usesuper | usecatupd | passwd | valuntil
----------+----------+-------------+----------+----------+-----------+----------+----------
postgres | 26 | t | t | t | t | ******** |
si | 27 | t | f | t | t | ******** |
nrg | 30 | t | f | t | t | ******** |
testuser | 28 | t | f | t | t | ******** |
sm | 31 | t | f | t | t | ******** |
tc | 32 | t | f | t | t | ******** |
nrgadmin | 33 | t | f | t | t | ******** |
dude | 29 | t | f | t | t | ******** |
ken | 34 | t | f | t | t | ******** |
(9 rows)

Now if I unset the PGDATABASE...

si(at)guinness > unset PGDATABASE
si(at)guinness > echo $PGDATABASE

si(at)guinness > psql -c "select * from pg_user"
psql: FATAL 1: Database "testuser" does not exist in the system catalog.

I get what you get.

So I can use the -d flag (for database), with PGDATABASE unset

si(at)guinness > psql -d bugdb -c "select * from pg_user"
usename | usesysid | usecreatedb | usetrace | usesuper | usecatupd | passwd | valuntil
----------+----------+-------------+----------+----------+-----------+----------+----------
postgres | 26 | t | t | t | t | ******** |
si | 27 | t | f | t | t | ******** |
nrg | 30 | t | f | t | t | ******** |
testuser | 28 | t | f | t | t | ******** |
sm | 31 | t | f | t | t | ******** |
tc | 32 | t | f | t | t | ******** |
nrgadmin | 33 | t | f | t | t | ******** |
dude | 29 | t | f | t | t | ******** |
ken | 34 | t | f | t | t | ******** |
(9 rows)

Does that make any sense?

s.

> Thanks,
> Annie
>
>
> From: Stephen Ingram <ingram(at)samsix(dot)com>
>
> >Reply-To: ingram(at)samsix(dot)com
> >To: "Annie Bai" <annie_job(at)hotmail(dot)com>, pgsql-novice(at)postgresql(dot)org
> >Subject: Re: [NOVICE] existence of user
> >Date: Sat, 2 Feb 2002 19:35:27 -0500
> >
> >On Saturday 02 February 2002 07:18 pm, Annie Bai wrote:
> > > Hi,
> > >
> > > After I used 'create user', Is there a database to keep all the
> >
> >information
> >
> > > about users? How can i check the existence of users?
> > >
> > > Thanks,
> > > Yan
> >
> >Hi,
> >
> >Sure. Check out the pg_user table.
> >
> >Postgres 'system' tables all seem to start with 'pg_'
> >
> >si(at)guinness > psql -c "select * from pg_user"
> > usename | usesysid | usecreatedb | usetrace | usesuper | usecatupd |
> >passwd | valuntil
> >----------+----------+-------------+----------+----------+-----------+----
> >------+---------- postgres | 26 | t | t | t
> > | t | ******** |
> > si | 27 | t | f | t | t |
> >******** |
> > nrg | 30 | t | f | t | t |
> >******** |
> > testuser | 28 | t | f | t | t |
> >******** |
> > sm | 31 | t | f | t | t |
> >******** |
> > tc | 32 | t | f | t | t |
> >******** |
> > nrgadmin | 33 | t | f | t | t |
> >******** |
> > dude | 29 | t | f | t | t |
> >******** |
> > ken | 34 | t | f | t | t |
> >******** |
> >(9 rows)
> >
> >steve
> >
> > > _________________________________________________________________
> > > Get your FREE download of MSN Explorer at
> >
> >http://explorer.msn.com/intl.asp.
> >
> > > ---------------------------(end of
> > > broadcast)--------------------------- TIP 4: Don't 'kill -9' the
> > > postmaster
> >
> >---------------------------(end of broadcast)---------------------------
> >TIP 4: Don't 'kill -9' the postmaster
>
> _________________________________________________________________
> Join the world’s largest e-mail service with MSN Hotmail.
> http://www.hotmail.com
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Stephen Ingram 2002-02-03 01:54:43 Re: existence of user
Previous Message Annie Bai 2002-02-03 01:37:19 Re: existence of user