1

I am using fallowing scripts for Create a user.

CREATE ROLE readonly LOGIN PASSWORD 'thePwd';

-- Existing objects

GRANT CONNECT ON DATABASE the_db TO readonly;

GRANT USAGE ON SCHEMA public TO readonly;

GRANT SELECT ON ALL TABLES IN SCHEMA public TO readonly;

GRANT SELECT ON ALL SEQUENCES IN SCHEMA public TO readonly;

GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA public TO readonly;

After Create User & Role; the "readonly" user have "SELECT" permission. No Drop or Truncate rights. But "readonly" user have right "Alter Table" command.

How can I restrict for a specific user "Alter Table" rights?

Is there a simple example?

6
  • It shouldn't have, based on the commands shown. Commented Sep 2, 2015 at 12:01
  • Is there a sample script? Commented Sep 2, 2015 at 12:07
  • Did you CONNECT to the_db before the GRANT USAGE ON SCHEMA ... ? Commented Sep 2, 2015 at 12:17
  • Please show the command that works but shouldn't and the output of \dp tablename on the affected table Commented Sep 2, 2015 at 12:41
  • I used the above SQL Scripts, Step by step. The readonly user working very well as expected by SELECT scripts ( no Drop, no Truncate ) ; expect for 'ALTER TABLE SAMPLE ADD/DROP Column "column_sample" ' Commented Sep 2, 2015 at 14:24

1 Answer 1

2

The solution is at the following script;

create user dummy_user with nosuperuser encrypted password 'dummy_password';

GRANT CONNECT ON DATABASE the_db TO dummy_user;

GRANT USAGE ON SCHEMA public TO dummy_user;

GRANT SELECT ON ALL TABLES IN SCHEMA public TO dummy_user;

GRANT SELECT ON ALL SEQUENCES IN SCHEMA public TO dummy_user;

GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA public TO dummy_user;
Sign up to request clarification or add additional context in comments.

1 Comment

I am still facing issue after this :( Able to run alter command still.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.