create new databases or additional users.)
You can also use the PostgreSQL command-line client to create a new user by
typing psql along with name of the database and then use the CREATE
USER command to create a new user. Here is an example:
Click here to view code image
CREATE USER foobar ;
CAUTION
PostgreSQL allows you to omit the WITH PASSWORD portion of the
statement. However, doing so causes the user to be created with no
password. This is a security hole, so you should always use the WITH
PASSWORD option when creating users.
NOTE
When you are finished working in the psql command-line client, you can
type \q to get out of it and return to the shell prompt.
Deleting Database Users in PostgreSQL
To delete a database user, you use the dropuser command, along with the
user’s name, and the user’s access is removed from the default database, like
this:
Click here to view code image
matthew@seymour:~$ dropuser msmith
DROP USER
You can also log in to your database by using psql and then use the DROP
USER command. Here is an example:
Click here to view code image
matthew@seymour:~$ psql demodb
Welcome to psql, the PostgreSQL interactive terminal.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help on internal slash commands
\g or terminate with semicolon to execute query
\q to quit
demodb=# DROP USER msmith ;
DROP USER
demodb=# \q