2

I have problem with postgres. It is possible to force prefix "pg_" to create user in PostgreSQL? For example:

CREATE USER pg_admin PASSWORD 'qwerty';

I am using PostgreSQL 10.6

HOLz1919
  • 68
  • 5
  • 2
    Why would you want to do that? The `pg_` prefix is typically reserved for system owned and managed things. I would never name _anything_ that is user created with the `pg_` prefix –  Aug 20 '20 at 07:16
  • I'm working on an old project where we're doing the migration to another server. In my sql backups i have this user then i have to create it again. – HOLz1919 Aug 20 '20 at 07:21

1 Answers1

2

This limitation has been in effect since version 9.6, where system roles starting with pg_ were introduced.

You could create a role with a different name and then update rolname in pg_authid, but that would be a bad idea, since PostgreSQL treats such roles differently than others. For example, the role would not be dumped by pg_dumpall -r.

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263
  • 1
    This way don`t help me but thank you for the answer. I solved my problem by replacing the name in the backup files, so I didn't need that prefix anymore. – HOLz1919 Aug 20 '20 at 11:36