简体   繁体   English

创建一个触发器,将角色授予每个新创建的用户

[英]Creating a trigger that grants a role to every new created user

I'm having a problem with creating a trigger that grants a role each time I create a new user how can I do it?我在创建每次创建新用户时授予角色的触发器时遇到问题,我该怎么做?

CREATE TRIGGER  grant_role_to_user
AFTER  insert ON "here I need the right table" 
FOR EACH ROW
BEGIN
    GRANT role_1 to : NEW.USERNAME
END;
/

I tried the table all_users, dba_users;我尝试了表 all_users、dba_users; but it gives me an error "can't create a trigger on this view"但它给了我一个错误“无法在此视图上创建触发器”

using oracle 10g使用 oracle 10g

Include GRANT ROLE into a script you use to create new users, ieGRANT ROLE包含到用于创建新用户的脚本中,即

create user        mike     identified by lion;
grant role_1 to    mike;

I think you dont need trigger for it.我认为你不需要trigger它。

Just assign this role to public and every user will have this role assigned.(including user that will be created in the future).只需将此role分配给public ,每个用户都会分配此角色。(包括将来创建的用户)。 But be aware about what you are doing.但要注意你在做什么。 You really mean it.你是认真的。

grant role_1 to public;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 SHOW GRANTS TO user ''usename' with filter on role (SNOWFLAKE) - SHOW GRANTS TO user ''usename" with filter on role (SNOWFLAKE) Oracle SQL:在创建视图后触发添加授权 - Oracle SQL: Trigger to add grants after creating view 创建仅在创建新表时运行的触发器 - Creating a trigger to only run when a new table is being created 在 Postgres 中创建新角色 - Creating new Role in Postgres 创建一个新数据库-用户定义的存储过程将自动创建 - Creating a new database - A user defined stored procedure is getting created automatically 许多拨款后删除postgres角色和数据库 - Dropping postgres role and database after many grants 创建新表时,在插入之前创建触发器生成ID列值 - Creating a trigger generating ID column value before insert when new tables is created SQL Server:创建过程/触发器以为另一种订单的每种类型创建新订单 - SQL Server : creating a procedure/trigger to create a new order for every type of another order 新用户创建后创建新记录的触发器在 PostgreSQL 中不起作用 - Trigger for creating a new record after new user creation doesn't work in PostgreSQL 服务器上每个数据库中的每个用户及其角色 - Each user and their role in every database on the server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM