Thread: Does a user have usage on a schema?

Does a user have usage on a schema?

From
"Walker, Jed S"
Date:

How can I query the database to determine if a user has usage on a particular schema, and how can I query the database to find out all the  schemas a user has usage on?

Thanks in advance,

      Jed S. Walker



Re: [despammed] Does a user have usage on a schema?

From
Andreas Kretschmer
Date:
am  29.06.2005, um  8:57:32 -0600 mailte Walker, Jed S folgendes:
> How can I query the database to determine if a user has usage on a
> particular schema, and how can I query the database to find out all the
> schemas a user has usage on?

start psql with -E and type "\n" to see all schemas and the underlaying
select. Now you can modify this select to select all schemas for a user.


Regards, Andreas
--
Andreas Kretschmer    (Kontakt: siehe Header)
Heynitz:  035242/47212,      D1: 0160/7141639
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net
 ===    Schollglas Unternehmensgruppe    ===

Re: Does a user have usage on a schema?

From
Bruno Wolff III
Date:
On Wed, Jun 29, 2005 at 08:57:32 -0600,
  "Walker, Jed S" <Jed_Walker@cable.comcast.com> wrote:
> How can I query the database to determine if a user has usage on a
> particular schema, and how can I query the database to find out all the
> schemas a user has usage on?

The has_schema_privilege function will allow you to check if a user
has access to a schema. You can use pg_users to get a list of all
users and pg_namespace can be used to get a list of all schemas.

Re: Does a user have usage on a schema?

From
"Walker, Jed S"
Date:
Thanks Bruno. I found the definitions for the has_schema_privilege and
it appears it'll work.

Also, how can I query against pg_namespace to find out what schemas a
user has. I've tried something like

Select * from pg_namespace where 'username' = any(nspacl);

I'd like to get a listing of rows such as

Schema1
Schema2
schema7

But that (and some other similar attempts) aren't working. How can I do
this?

Thanks again,

Jed.

-----Original Message-----
From: Bruno Wolff III [mailto:bruno@wolff.to]
Sent: Wednesday, June 29, 2005 9:37 AM
To: Walker, Jed S
Cc: pgsql-novice@postgresql.org
Subject: Re: Does a user have usage on a schema?

On Wed, Jun 29, 2005 at 08:57:32 -0600,
  "Walker, Jed S" <Jed_Walker@cable.comcast.com> wrote:
> How can I query the database to determine if a user has usage on a
> particular schema, and how can I query the database to find out all
> the schemas a user has usage on?

The has_schema_privilege function will allow you to check if a user has
access to a schema. You can use pg_users to get a list of all users and
pg_namespace can be used to get a list of all schemas.

Re: Does a user have usage on a schema?

From
Bruno Wolff III
Date:
On Wed, Jun 29, 2005 at 09:59:06 -0600,
  "Walker, Jed S" <Jed_Walker@cable.comcast.com> wrote:
> Thanks Bruno. I found the definitions for the has_schema_privilege and
> it appears it'll work.
>
> Also, how can I query against pg_namespace to find out what schemas a
> user has. I've tried something like
>
> Select * from pg_namespace where 'username' = any(nspacl);

You would do something like:

SELECT nspname
  FROM pg_namespace
  WHERE
    has_schema_privilege('bruno', nspname, 'usage')
;

For example:
area=> select nspname from pg_namespace where has_schema_privilege(
area(> 'bruno', nspname, 'usage');
      nspname
--------------------
 pg_catalog
 information_schema
 public
(3 rows)