Re: Update "usename" in pg_user

From: Paul Smith* <paul(at)pscs(dot)co(dot)uk>
To: pgsql-admin(at)lists(dot)postgresql(dot)org
Subject: Re: Update "usename" in pg_user
Date: 2023-11-14 13:05:15
Message-ID: 79d4ec67-40b2-427f-aa40-2588bacb4556@pscs.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On 14/11/2023 12:56, Bernd Lentes wrote:
> Due to change of the LDAP server I need to modify the username now.
> From firstname.lastname to firstname(dot)lastname(at)helmholtz-munich(dot)de(dot)
> I tried the following (just for one user to test it):
>
> update pg_user set usename = 'usename(at)helmholtz-munich(dot)de' where usename = 'dorota.germann';

1) don't update system tables directly unless you absolutely must

ALTER USER <username> RENAME TO <new_username> is what you want

2) To use characters other than alphanumeric or _ then you need to use
double quotes

So:

ALTER USER dorota.germann RENAME TO "dorota(dot)germann(at)helmholtz-munich(dot)de";

should do the job

Paul

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Bernd Lentes 2023-11-14 13:20:10 RE: Update "usename" in pg_user
Previous Message Bernd Lentes 2023-11-14 12:56:24 Update "usename" in pg_user