Sample Exam Questions

From the objective of OSS-DB Exam Silver
S2.1 Installation (Usage of initdb command)

Sample Question


Choose the three most accurate descriptions about creating a database cluster by running the initdb command.

  1. By default, only the user who executes the command can access the files in the database cluster.

  2. The command is executed by the user who will become the owner of the database server process.

  3. The command should be run as the root user for enhanced security.

  4. The created database cluster contains two template databases and one regular database.

  5. Because the character set encoding specified during database cluster creation applies to all databases within the cluster, it is crucial to be careful about what is specified.

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

Answer and Explanation

After installing the PostgreSQL program, you must create a database cluster by running the initdb command to make it available as a database server.

The database cluster that is created is owned by the user who runs the initdb command, and by default, only that user can access it. However, with an option set during creation, read access can be granted to users in the same group as the user. This can be useful, for example, when backing up database files.

Since only the user who executed initdb can access the files of the database cluster, the database server's processes must also be run by the same user. In other words, the user who will become the owner of the server process must execute initdb.

The root user on Unix/Linux is a powerful administrative user who can access all the files on the system. However, PostgreSQL has restrictions that prevent the root user from running the database server processes. This is to prevent root privileges from being compromised by unexpected security vulnerabilities. Therefore, the root user cannot execute initdb either.

The created database cluster will contain two template databases, template0 and template1, and a regular database called postgres.

Options are available when running initdb to specify the default character set encoding. The two databases, template1 and postgres, are created with this encoding. Also, when adding a database, for example with the createdb command, a copy of template1 is created by default, so the encoding is the same. So you should be careful what you specify, but it is only the default, and you can use a different encoding for your database.

So the correct answers are A, B, and D.