How to CREATE USER in PostgreSQL
CREATE USER adds a new user to a PostgreSQL database cluster. You must be a database superuser to use this command.
Examples
1. Create a user with no password:
CREATE USER jonathan;
2. Create a user with a password:
CREATE USER davide WITH PASSWORD 'jw8s0F4';
3. Create a user with a password that is valid until the end of 2004. After one second has ticked in 2005, the password is no longer valid.
CREATE USER xen WITH PASSWORD 'jw8s0F4' VALID UNTIL '2005-01-01';
4. Create an account where the user can create databases:
CREATE USER manuel WITH PASSWORD 'jw8s0F4' CREATEDB;
CREATE USER manuel WITH PASSWORD 'jw8s0F4' CREATEDB;
Compatibility
The CREATE USER statement is a PostgreSQL extension. The SQL standard leaves the definition of users to the implementation.
The CREATE USER statement is a PostgreSQL extension. The SQL standard leaves the definition of users to the implementation.
Comments