Sample Exam Questions

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

Sample Question

2.03

Choose two appropriate descriptions for the createdb command.

createuser -h pgserver -p 5432 -d -U john

 
  1. By default, three databases are created: template0, template1, and postgres.
  2. The database cluster must be running.
  3. A database can be created on a database cluster running on other hosts on the network.
  4. Anyone with user privileges on the database cluster can execute it.
  5. It is also available for non-PostgreSQL databases such as MySQL.

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

Answer and Explanation

A PostgreSQL database instance consists of a database cluster. This cluster, which is made up of multiple databases, is managed by a single set of server processes.
You create the database cluster with the initdb command. Immediately after creation, it contains three databases: template0, template1, and postgres.
To add a new database, you can connect to the database and issue the SQL CREATE DATABASE command. Alternatively, you can run the createdb command from the OS command line. This command connects to the database and internally issues the CREATE DATABASE command to create a new database.
Since you cannot create a new database without connecting to it, the database cluster must be running. With the -h and -p options of the createdb command, you can specify the host name and port number to connect to. This allows you to connect to a database running on another host on the network and create a new database there.
Creating a database requires the special CREATEDB privilege. Just having the right to connect to the database is not enough.
The configuration of a database instance varies greatly depending on the type of RDBMS. The SQL command CREATE DATABASE is a PostgreSQL extension, as is the createdb command. Please note that the method of creating a database depends on the type of RDBMS.

Therefore, the correct answers are B and C.