In this PostgreSQL post explains how to use the PostgreSQL CREATE USER statement with syntax and examples.
The CREATE USER statement creates a database account that allows you to log into the PostgreSQL database.
The syntax for the CREATE USER statement in PostgreSQL is:
The name of the database account that you wish to create.
The password to assign to user_name.
The date/time value when the password will expire. If you never want the password to expire, you set expiration to 'infinity'.
Let's look at how to create a user in PostgreSQL using the CREATE USER statement.
For example:
In this example, the CREATE USER statement would create a new user called AODBA. This new user would not have a password, but you could use the ALTER USER statement to assign a password later.
If you wanted to assign a password at the time that the user is created, you could change the CREATE USER statement as follows:
This would create a user called AODBA with a password of 'fantastic'.
If you wanted to create the user AODBA with a password of 'fantastic' that expires on January 1, 2015, you would use the CREATE USER statement as follows:
If you wanted the password for the user AODBA to never expire, you would use the CREATE USER statement as follows: