GRANT for different objects separate. GRANT ING based on non GRANT rights to the circuit inside. Similarly, providing GRANT for a schema does not give rights to tables inside.
If you have SELECT rights from the table, but you cannot see it in the schema in which it is contained, you cannot access the table.
The verification of rights is carried out in the following order:
Do you have 'USAGE' on the schema? No: Reject access. Yes: Do you also have the appropriate rights on the table? No: Reject access. Yes: Check column privileges.
Your confusion may arise due to the fact that the public scheme has, by default, GRANT all rights to the public role, of which each user / group is a member. Thus, everyone is already using this scheme.
Phrase:
(provided that the own requirements for privileges of objects are also fulfilled)
It is said that to use the objects inside it, you must have USAGE in the scheme, but the presence of USAGE in the scheme is not enough for using objects in the scheme, you must also have rights to the objects themselves.
It is like a directory tree. If you create somedir directory with somedir file inside it, then set it so that only your own user rwx------ access to the directory or file ( rwx------ mode rwx------ in the directory, rw------- mode rw------- in the file), then no one else will be able to rw------- list the directory to see that the file exists.
If you granted read permissions for the file ( rw-r--r-- mode), but did not change the permissions for the directory, that would not matter. No one could see the file in order to read it, because they do not have rights to list the directory.
If instead you install rwx-r-xr-x in the directory, setting it up so that people can view and view the directory, but without changing the file permissions, people could list the file, but could not read it, because they would not have access to the file.
You need to set both permissions so that people can actually view the file.
Same thing in Pg. You need both USAGE rights and object rights schemes to perform actions on the object, for example, SELECT , from the table.
(The analogy falls a bit in that PostgreSQL does not yet have row-level security, so the user can still βseeβ that the table exists in the SELECT schema directly from pg_class . They cannot interact with it anyway, so it's just part of the list that is not exactly the same.)