In PostgreSQL, when granting sequences, can I grant only USAGE instead of both SELECT, USAGE?
Asked Answered
T

1

2

I read answers about granting sequences in PostgreSQL. Generally, they say to grant both SELECT, USAGE. I wonder if I can grant only USAGE. Which one is best practice in granting sequences and why?

Tannie answered 28/7, 2017 at 9:12 Comment(0)
H
8

Quote from the manual

SELECT privilege

For sequences, this privilege also allows the use of the currval function.

USAGE privilege

For sequences, this privilege allows the use of the currval and nextval functions.

(emphasis mine)

So the answer is: if you want to allow the usage of nextval() you will have to grant the USAGE privilege. If you grant USAGE, the SELECT privilege is not needed.

Hydrodynamics answered 28/7, 2017 at 9:23 Comment(1)
Very solid. Thank you.Tannie

© 2022 - 2024 — McMap. All rights reserved.