本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
Examples
以下示例向用户 授予对 SALES 表的 SELECT 权限。fred
.
grant select on table sales to fred;
以下示例向用户 授予对 QA_TICKIT schema 中所有表的 SELECT 权限。fred
.
grant select on all tables in schema qa_tickit to fred;
以下示例向用户组 QA_USERS 授予对 schema QA_TICKIT 的全部 schema 权限。Schema 权限包括 CREATE 和 USAGE。USAGE 向用户授予访问 schema 中对象的权限,但不授予对这些对象的 INSERT 或 SELECT 之类的权限。单独授予对每个对象的权限。
create group qa_users; grant all on schema qa_tickit to group qa_users;
以下示例向组 QA_USERS 中的所有用户授予对 QA_TICKIT schema 中的 SALES 表的所有权限。
grant all on table qa_tickit.sales to group qa_users;
以下命令序列说明,具有对 schema 的访问权限并不表示授予对 schema 中的表的权限。
create user schema_user in group qa_users password 'Abcd1234'; create schema qa_tickit; create table qa_tickit.test (col1 int); grant all on schema qa_tickit to schema_user; set session authorization schema_user; select current_user; current_user -------------- schema_user (1 row) select count(*) from qa_tickit.test; ERROR: permission denied for relation test [SQL State=42501] set session authorization dw_user; grant select on table qa_tickit.test to schema_user; set session authorization schema_user; select count(*) from qa_tickit.test; count ------- 0 (1 row)
以下命令序列说明,具有对视图的访问权限并不意味着具有对基础表的访问权限。虽然名为 VIEW_USER 的用户已被授予 VIEW_DATE 的所有权限,但该用户无法从 DATE 表中选择数据。
create user view_user password 'Abcd1234'; create view view_date as select * from date; grant all on view_date to view_user; set session authorization view_user; select current_user; current_user -------------- view_user (1 row) select count(*) from view_date; count ------- 365 (1 row) select count(*) from date; ERROR: permission denied for relation date
以下示例向用户 cust_name
授予对 cust_phone
表的 cust_profile
和 user1
. 列的 SELECT 权限。
grant select(cust_name, cust_phone) on cust_profile to user1;
以下示例向 cust_name
组授予对 cust_phone
和 cust_contact_preference
列的 SELECT 权限,并授予对 cust_profile
表的 sales_group
列的 UPDATE 权限。
grant select(cust_name, cust_phone), update(cust_contact_preference) on cust_profile to group sales_group;
下面的示例演示如何使用 ALL 关键字向 cust_profile
组授予对 sales_admin
表的三列的 SELECT 和 UPDATE 权限。
grant ALL(cust_name, cust_phone,cust_contact_preference) on cust_profile to group sales_admin;
以下示例向用户 cust_name
授予对 cust_profile_vw
视图的 user2
列的 SELECT 权限。
grant select(cust_name) on cust_profile_vw to user2;
为数据共享授予 USAGE 权限的示例
这是 Amazon Redshift 数据共享功能的预发布文档,目前为预览版。文档和功能均可能随时更改。我们建议您只在测试集群中使用此功能,而不要在生产环境中使用。有关预览版条款和条件,请参阅
AWS 服务条款 |
以下示例向指定的命名空间授予对Salesshare
数据共享的 USAGE 权限。
GRANT USAGE ON DATASHARE Salesshare TO NAMESPACE 'f5a0b31c-f2c7-45d6-ba3e-0d53ad027e8b';
以下示例向 Bob 授予对 的 USAGE Sales_db
权限。
GRANT USAGE ON DATABASE Sales_db TO Bob;
以下示例 GRANT USAGE 对 Sales_schema
的 权限Analyst_group
。
GRANT USAGE ON SCHEMA Sales_schema TO GROUP Analyst_group;
授予 ASSUMEROLE 权限的示例
以下是授予 ASSUSEROLE 权限的示例。
以下示例为 IAM 角色的 用户授予执行 COPY reg_user1
操作的 ASSUMEROLE Redshift-S3-Read
权限。
grant assumerole on 'arn:aws:iam::123456789012:role/Redshift-S3-Read' to reg_user1 for copy;
以下示例为 reg_user1
IAM 角色链 的用户授予 ASSUMEROLE 权限RoleA
以执行 RoleB
UNLOAD 操作。
grant assumerole on 'arn:aws:iam::123456789012:role/RoleA,arn:aws:iam::210987654321:role/RoleB' to reg_user1 for unload;
以下是使用 IAM 角色链 RoleA
、 的 UNLOAD 命令的示例RoleB
。
unload ('select * from venue limit 10') to 's3://companyb/redshift/venue_pipe_' iam_role 'arn:aws:iam::123456789012:role/RoleA,arn:aws:iam::210987654321:role/RoleB';