Set read-only for 1 table only in postgresql

I want to set read-only for only one table in the database. I tried the command

ALTER TABLE table SET READ ONLY;

      

but that won't work.

Is there a way to do this?

+3


source to share


1 answer


I saw the answer, I hope it is helpful



REVOKE INSERT, UPDATE, DELETE, TRUNCATE
ON ALL TABLES IN SCHEMA public
FROM public, <target_role>;

      

Maybe add more roles to the list, but don't forget the public's role. Maybe add more schemas to the list, but don't forget that the schema is publicly available.

+1


source







All Articles