RefLib

Reference library for AI

Back

postgresql_16:3.2.9.4 Schemas and Privileges

PostgreSQL 16 > The SQL Language > Data Definition > Schemas > Schemas and Privileges

By default, users cannot access any objects in schemas they do not own. To allow that, the owner of the schema must grant the USAGE privilege on the schema. By default, everyone has that privilege on the schema public. To allow users to make use of the objects in a schema, additional privileges might need to be granted, as appropriate for the object.

A user can also be allowed to create objects in someone else's schema. To allow that, the CREATE privilege on the schema needs to be granted. In databases upgraded from PostgreSQL 14 or earlier, everyone has that privilege on the schema public. Some usage patterns (see postgresql_16:3.2.9.6) call for revoking that privilege: REVOKE CREATE ON SCHEMA public FROM PUBLIC; (The first “public” is the schema, the second “public” means “every user”. In the first sense it is an identifier, in the second sense it is a key word, hence the different capitalization; recall the guidelines from (see postgresql_16:3.1.1.1).)

Back