PostgreSQL: Upgrade a User to be a Superuser?

In this article we are going to cover how to upgrade a user to be a superuser in PostgreSQL. In PostgreSQL there is a unique term “role”, the term “role” will be discussed later because it’s a complicated feature by itself.

TL;DR: ALTER USER username WITH SUPERUSER;

Upgrade a User to be a Superuser

In PostgreSQL ALTER USER the statement we use to alter a user’s grants and properties. You can learn more about ALTER USER statement from this link.

postgres=# ALTER USER testuser WITH SUPERUSER;
ALTER ROLE

Also reverting is possible:

postgres=# ALTER USER testuser WITH NOSUPERUSER;
ALTER ROLE

Use Case

You can alter a user with superuser grants now, but we haven’t talk about use case of this statement and where to use it. After creating a user, if we need global administration features on a user we can update a user to be a superuser. We also, can, revoke superuser privileges back with same statement.

A new post everyday, subscribe now and don’t miss it!

Subscribe to our newsletter for cool news

Hi! I’m an IT Specialist

I want to hear from you! I am Working with enterprises for 10+ years to improve their infrastructure and efficiency.

Get in touch with me.

Leave a Reply

Discover more from Empower. Innovate. Transform.

Subscribe now to keep reading and get access to the full archive.

Continue reading