User foo can SELECT from table table1
The last GRANT statement results in a syntax error
User bar can be SELECTed from table table1
User bar can be SELECTed from table table
※This sample exam is different from those that appear in the actual OSS-DB Exam.
2019/05/30
To grant various access privileges on objects such as tables, use the GRANT statement. The target object is not limited to tables, but sequences, functions, schemas, table spaces, and so on.
The syntax of a general GRANT statement is
GRANT {kind of access right (SELECT etc.)}
ON [Object type (can be omitted in the case of TABLE)] Object name
TO user name (or role name);
In addition, you can grant the user all the privileges granted to the role at once.
GRANT role name TO user name;
GRANT user1 TO user2;
In PostgreSQL implementation, users and roles are exactly the same, then so all of the privileges granted to user1 are granted to user2.
In the example case,
With the third GRANT statement, user SELECT privilege is granted to user foo and user bar is granted privilege of user foo by the fifth GRANT statement, so users foo and bar have SELECT privilege on table 1.
In the fourth ALTER TABLE statement, we changed table2's owner to foo.
This will cause foo to have access to table 2, which is also granted to bar by the fifth GRANT statement.
Therefore, the correct answer is A, D, E.