Sample Exam Questions

From the objective of OSS-DB Exam Silver
S2.5 Basic server administration (Concept of database role / user)

Sample Question


Choose one action that cannot be performed using PostgreSQL's GRANT command:

  1. Grant a user access to objects, such as SELECT from a table.

  2. Grant a role access to objects, such as SELECT from a table.

  3. Grant a role the permission to create a database (CREATEDB).

  4. Grant all privileges assigned to a role to a user in a batch.

  5. Grant all privileges assigned to a role to another role in a batch.

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

Answer and Explanation

A role (ROLE) is best understood as a collection of privileges that can be executed on a database. While the database allows fine-grained control over access privileges to objects such as tables, instead of granting privileges directly to individual users, you can grant privileges to roles and then grant those roles to users, such as when you want to grant the same privileges to multiple users.

Permissions to access objects are granted with GRANT, specifying the permission type, object name, and user name, as in GRANT SELECT ON table1 TO user1. You can also grant permissions to a role by specifying the role name instead of the user name, for example GRANT SELECT ON table1 TO role1.

To grant a user with privileges granted to a role, use GRANT role1 TO user1. In this case, the role role1 is granted to user1, so if you subsequently grant role1 with additional privileges, user1 is automatically granted with those privileges.
The role can be granted to another role, as in GRANT role TO role2.

In addition to object privileges, databases also grant privileges such as login (LOGIN), user creation (CREATEROLE), and database creation (CREATEDB), which PostgreSQL grants with ALTER ROLE (or ALTER USER) rather than GRANT (Of course, it can also be granted when CREATE ROLE/USER is performed).

This is a question where you need to select the incorrect option, so the correct answer is C.