Is there an SQL statement to create an insert-only table in PostgreSQL (v9.5); in other words, with write permissions it is possible to add rows, but not possible to change existing rows?
CREATE TABLE public.newtable
Tables are only updated with INSERT
statements, not using UPDATE
or DELETE
statements.
This command will allow you to REVOKE any privileges you may have GRANTed:
REVOKE ALL ON TABLE newtable FROM PUBLIC;
Then, you'll want to GRANT the INSERT privilege to the role(s) that need to insert data:
GRANT INSERT ON TABLE newtable TO role;
Despite the above, the database/schema owner can still do whatever he or she would like. So, you should consider creating a specific role for the purpose.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With