PostgreSQL, Software Development

PostgreSQL – Create superusers

Tested On

PostgreSQL 10.5


Depending on a given installation of PostgreSQL, the default superuser may not be readily available but it is called postgres.

Users are Roles, Roles are Users

PostgreSQL represents users as roles. There are roles that can log in called login roles. There are roles contain other roles.  There are roles that both can log in and contain other roles.

For this post, we’ll just briefly touch on creating login roles and superuser roles.

Users and Groups

In the past, PostgreSQL uses the terms user and groups. However, in recent versions, those are no longer in use. For backward compatibility, CREATE USER and CREATE GROUP still work in the current version, but shun them and use CREATE ROLE instead.

Create Login Roles

To create login roles, follow the example below.

The VALID line is optional and specifies when the role should expire and lose its privileges; the default is infinity, which means the role never expires. The CREATEDB modifier grants database creation rights to the new role.

Create Superuser Roles

First and foremost, we can create another superuser roles if the current role (account or user) is also a superuser, e.g., the initial postgres role

For more information, please visit

You Might Also Like