Sample Exam Questions

From the objective of OSS-DB Exam Silver
- Operation and Management - Installation method (How to use initdb command)

Sample Question

1.23

Choose two answers from below that are true when creating a database cluster using the initdb command on Linux.

  1. Since initdb needs to be run as an administrator user, run it as root user.
  2. The directory of the database cluster specifies either a new directory or an existing empty directory.
  3. If existing files exist in the database cluster directory, they are deleted.
  4. Specify the directory of the database cluster using the command line argument of initdb or the environment variable PGDATA.
  5. The character set specified by initdb is common to all databases in the cluster.

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

Answer and Explanation

initdb is a command to create a new database cluster. The user who executes the command becomes the administrator user of the database, and only the administrator user can read and write the file to be created, but this is the "database" administrator user; and the OS administrator user (root) is different. The initdb command is restricted from running as the root user for security reasons.

The directory where the database cluster is created is specified by the command line argument of initdb, but if omitted, the environment variable PGDATA is used. If this directory does not exist, it will be newly created, but if you specify an existing directory, that directory must be empty. An error occurs if the directory is not empty.

For example, when creating a database cluster in / usr / local / pgsql / data, it is often that / usr / local / pgsql does not have write privileges for general users. In this case, if the data directory does not exist, it will be an error to create the data directory when initdb is executed. once mkdir with root authority, create an empty data directory, chown to the database administrator user chmod, chmod the permission to 700 and execute initdb.

You can specify the default character set when running initdb. Since this is the character set of template 1, when you create a new database with CREATE DATABASE, it defaults to the character set of the database, but you can create a database of another character set by specifying it with parameters.

 

Therefore, the correct answers are B and D.