Re: Users and object privileges maintenance - Mailing list pgsql-general

From Adrian Klaver
Subject Re: Users and object privileges maintenance
Date
Msg-id d48e9d9e-dee7-4410-86f4-92049d064ca8@aklaver.com
Whole thread Raw
In response to Re: Users and object privileges maintenance  (Dominique Devienne <ddevienne@gmail.com>)
List pgsql-general
On 2/18/24 02:12, Dominique Devienne wrote:
> On Sat, Feb 17, 2024 at 10:50 PM Lok P <loknath.73@gmail.com 
> <mailto:loknath.73@gmail.com>> wrote:
> 
>     We were having past experience in Oracle and are newly getting moved
>     to postgres database. [...]
>     So I just wanted to understand if these grants and privileges for
>     objects/users are given and maintained in a similar way in postgres
>     database
> 
> 
> Yes they are. Having done that move from Oracle to PostgreSQL, here are 
> a few pointers.
> 


More information on a couple of points I have found trips people up on 
occasion.

> 
> "DBAs" in PostgreSQL are ROLEs with the SUPERUSER privilege. (e.g. the 
> built-in postgres ROLE)

This is a convention not a rule. More specifically it is the name of the 
OS user that runs initdb. It can be overridden by using -U <some_name) 
with initdb.  I bring it up because this causes confusion, in particular 
with the folks using the Homebrew and Postgres.app packages found here:

https://www.postgresql.org/download/macosx/

In those cases the default superuser generally is the name of the OS 
user that downloaded and installed the package.

> 
> USERs are ROLEs with the LOGIN privilege.

Again a convention not a rule. This harks back to the days(v 8.0-) when 
Postgres had groups and users.

Per

https://www.postgresql.org/docs/current/sql-createuser.html

"CREATE USER is now an alias for CREATE ROLE. The only difference is 
that when the command is spelled CREATE USER, LOGIN is assumed by 
default, whereas NOLOGIN is assumed when the command is spelled CREATE 
ROLE."

It is entirely possible to CREATE USER ... WITH NOLOGIN ...

-- 
Adrian Klaver
adrian.klaver@aklaver.com




pgsql-general by date:

Previous
From: Pavel Luzanov
Date:
Subject: Re: Users and object privileges maintenance
Next
From: Laura Smith
Date:
Subject: Function inserting into tstzrange ? (syntax error at or near...)