Create database user, alter and drop username

PostreSQL tutorial – Create/Alter/Drop User

Create postgresql user

Create database user, alter user password and drop username. Rename, modify user.

Syntax

CREATE USER user_name;

Example

CREATE USER user_test;

Alter postgresql user

Syntax

ALTER USER user_name [ [ WITH ] option [ ... ] ]
where option can be:
	SUPERUSER | NOSUPERUSER
	CREATEDB | NOCREATEDB
	CREATEROLE | NOCREATEROLE
	CREATEUSER | NOCREATEUSER
	INHERIT | NOINHERIT
	LOGIN | NOLOGIN
	REPLICATION | NOREPLICATION
	CONNECTION LIMIT connlimit
	[ ENCRYPTED | UNENCRYPTED ] PASSWORD 'password'
	VALID UNTIL 'timestamp'

ALTER USER user_name 
	RENAME TO new_user_name ;

Example

ALTER USER user_test SUPERUSER;
ALTER USER user_test RENAME TO user_test_2;

Drop postgresql user

Syntax

DROP USER user_name;

Example

DROP USER user_test;