Sample Exam Questions
createuser -h pgserver -p 5432 -d -U john
※This sample exam is different from those that appear in the actual OSS-DB Exam.
2024/05/07
To create a database user, connect to the database with a user with privileges and issue SQL's CREATE USER.
PostgreSQL provides the createuser command, which is executed from the OS command line, and this internally connects to the database and executes CREATE USER (or more precisely, CREATE ROLE).
To connect to the database, specify the hostname where the target database is running, the port number, the username to use for the connection, etc. (if omitted, the default value is used, so it is not always necessary to specify).
The destination host is specified with the -h option, and the port number is specified with the -p option. The -U option is used to specify the connection username.
Also, to create a user, specify the username to create, the privileges to grant, etc.
The username to create is specified at the end of the command without options. The database privileges that can be granted include superuser privileges, database creation privileges, and user creation privileges. The -d option is specified to grant database creation privileges.
In the example command, the hostname (-h), port number (-p), and database creation privilege (-d) are correctly specified; however, '-U john' means to connect to the database as john, which is incorrect. If you delete ""-U"", it will be the correct command.
Therefore, the correct answer is D.
The options used for database connection are common to other client commands such as psql and createdb, so let's remember them all together.
© EDUCO All Rights Reserved.