Home > database >  Redshift access to only few columns in a view
Redshift access to only few columns in a view

Time:12-07

I have a view which is based on another view.

Example :

create or replace view old_view as select * from new_view

I don't want user to have access to all the columns in the old_view.

The new_view contains lots of PII data and since the old_view is based on the new_view, I want specific user to NOT have access to some of the columns in the old_view.

How do I do this?

CodePudding user response:

Instead of using SELECT * FROM new_view, you should include the list of columns that you specifically want to include in the view, eg:

CREATE OR REPLACE old_view AS SELECT column1, column2, column3 FROM new_view

This way, old_view will only contain the columns you allow and the user won't be able to access other columns (assuming that they are not permitted to access new_view).

CodePudding user response:

CREATE OR REPLACE old_view AS SELECT column1, column2, column3 FROM new_view.

GRANT SELECT( column1, column2)
ON new_view TO db_user ;

I'm getting the below error -

SQL Error [42703]: ERROR: column "column1" of relation "new_view" does not exist

  • Related