Sample Exam Questions

From the objective of OSS-DB Exam Silver
S2.2 Usage of server management tools (createuser/dropuser)

Sample Question

2.20

Choose one correct description for the createuser command that creates a database user.

 
  1. The createuser can only be used against a database running on a local host, and not against a database running on a remote host.

  2. At runtime, you are always prompted for the administrator user password.

  3. Because the postgres user is used when connecting to the database, the postgres user must be granted appropriate privileges.

  4. For security reasons, it is not possible to create a superuser with createuser, so you need to connect to the database, for example in psql, and execute create user (or create role).

  5. By default, a user with database connection privileges is created, but you can also create a role without connection privileges (ROLE) by specifying the option.

※This sample exam is different from those that appear in the actual OSS-DB Exam.
2024/05/07

Answer and Explanation

To create a database user, it is common to connect to the database and execute the SQL create user command, but PostgreSQL provides a utility command, createuser, that can be used to do this from the OS command line.
Note that in the PostgreSQL implementation, there is no distinction between users and roles, and SQL create user and create role are the same (the only difference is the default value). The createuser command connects to the database internally and issues the create role command, essentially doing the same thing as create role.

The default is to create a user only with database connection privileges without database creation, role creation, or superuser privileges. However, you can create a user with each of these privileges with the -d, -r, and -s options respectively. You can also create a role without database connection privileges with the -L option.

The database to connect to is specified by the environment variables PGHOST, PGPORT, and PGUSER, as well as the command-line options -h, -p, and -U, just as in other utilities such as psql. Therefore, it can be used for databases running on remote hosts, and any user with the appropriate privileges can connect.

You might be prompted for a password when connecting to the database, but this might not be the case because the authentication method depends on your configuration, and you can omit this by using a file such as .pgpass, even if password authentication is enabled.

So the correct answer is E.