0
点赞
收藏
分享

微信扫一扫

GreenPlum 行列权限控制

RJ_Hwang 2022-04-14 阅读 44

准备

drop table if exists salary;
create table salary (
	 id int  --唯一标识
	,name varchar(100)  --姓名
	,amount numeric  --工资
	,users varchar  --数据库用户
) distributed by (id);

insert into salary values 
	(1,'张三',5000,'tjbb1'),
	(2,'李四',6000,'tjbb2');

行级权限控制

  • 希望张三只能访问张三自己的数据,李四只能访问李四自己的数据
--通过该视图(外模式)访问数据
create or replace view user_salary as 
select * from salary
where users = user::varchar(64);
grant select on table user_salary to tjbb1;
grant select on table user_salary to tjbb2;

列级权限控制

  • 希望普通用户只能查看非工资的列,只有领导才能看工资列
--回收表的public权限
revoke all ON salary from public;
--授权列权限
grant select(id,name,users) on table salary to lingdao;
grant select(id,name,amount,users) on table salary to commonuser;

参考文章

举报

相关推荐

0 条评论