Sample Header Ad - 728x90

Insert- and Read-only table in Postgres

4 votes
2 answers
26599 views
I want to create an "immutable" Postgres database, where users can insert/select (write/read) data only, but can not update/delete (change/delete). I came to know there is FOR UPDATE lock, but did not get how to use it. Let's say for example I've the below table, how can I make it immutable (or, if I understood correctly, how can I use FOR UPDATE lock permanently)? CREATE TABLE account( user_id serial PRIMARY KEY, username VARCHAR (50) UNIQUE NOT NULL, password VARCHAR (50) NOT NULL, email VARCHAR (355) UNIQUE NOT NULL, created_on TIMESTAMP NOT NULL, last_login TIMESTAMP );
Asked by Hasan A Yousef (155 rep)
Mar 18, 2019, 08:01 PM
Last activity: Jan 17, 2023, 03:27 PM