Oracle:Authid Current_User的使用(2)
来源:互联网 发布:怎么做seo推广 编辑:程序博客网 时间:2024/05/28 15:24
我们知道,用户拥有的role权限在存储过程是不可用的。遇到这种情况,我们一般需要显式授权,如grant create table to usera;但这种方法太麻烦,有时候可能需要进行非常多的授权才能执行存储过程,实际上,oracle给我们提供了在存储过程中使用role权限的方法:修改存储过程,加入Authid Current_User时存储过程可以使用role权限。下面来举个例子:
SQL> select * from v$version;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
SQL> conn sjh/sjh
已连接。
SQL> create or replace procedure p_test
2 is
3 begin
4 execute immediate 'create table creat_table(id number)';
5 end;
6 /
已连接。
SQL> create or replace procedure p_test
2 is
3 begin
4 execute immediate 'create table creat_table(id number)';
5 end;
6 /
过程已创建。
SQL> exec p_test;
BEGIN p_test; END;
BEGIN p_test; END;
*
第 1 行出现错误:
ORA-01031: 权限不足
ORA-06512: 在 "SJH.P_TEST", line 4
ORA-06512: 在 line 1
第 1 行出现错误:
ORA-01031: 权限不足
ORA-06512: 在 "SJH.P_TEST", line 4
ORA-06512: 在 line 1
SQL>
SQL> select * from dba_role_privs where grantee='SJH';
GRANTEE GRANTED_ROLE ADM DEF
------------------------------ ------------------------------ --- ---
SJH RESOURCE NO YES
------------------------------ ------------------------------ --- ---
SJH RESOURCE NO YES
--实际上SJH用户有resource的角色,也就是说有建表的权限。
SQL> select * from dba_role_privs where grantee='SFX';
GRANTEE GRANTED_ROLE ADM DEF
------------------------------ ------------------------------ --- ---
SFX RESOURCE NO YES
SFX CONNECT NO YES
SFX PLUSTRACE NO YES
------------------------------ ------------------------------ --- ---
SFX RESOURCE NO YES
SFX CONNECT NO YES
SFX PLUSTRACE NO YES
SQL> create or replace procedure p_test
2 Authid Current_User
3 is
4 begin
5 execute immediate 'create table creat_table(id number)';
6 end;
7 /
2 Authid Current_User
3 is
4 begin
5 execute immediate 'create table creat_table(id number)';
6 end;
7 /
过程已创建。
SQL> exec p_test;
PL/SQL 过程已成功完成。
SQL> select * from creat_table;
未选定行
--在存储过程加了Authid Current_User选项,表建立成功。
0 0
- Oracle:Authid Current_User的使用(2)
- Oracle:Authid Current_User的使用2
- Oracle:Authid Current_User的使用
- Oracle:Authid Current_User的使用
- Oracle:Authid Current_User的使用
- Oracle:Authid Current_User的使用
- Oracle:Authid Current_User的使用
- Oracle:Authid Current_User的使用
- Authid Current_User的使用
- Authid Current_User的使用
- Authid Current_User的使用
- Oracle之AUTHID CURRENT_USER
- oracle Authid Current_User
- Oracle之AUTHID CURRENT_USER
- Oracle之AUTHID CURRENT_USER
- Oracle AUTHID CURRENT_USER
- oracle authid current_user详解
- oracle authid current_user详解
- eclipse package explorer视图中怎么让default package不显示?
- iOS runtime的应用实例
- Java中获取 ApplicationContext
- 缓冲区的设计:
- webkit webApp 开发技术要点总结
- Oracle:Authid Current_User的使用(2)
- Redis复制与可扩展集群搭建
- python 命令行如何查看与更换当前路径?
- Logstash中grok filter example例子
- 跑马灯实现的三种方式
- 数据库事务的四大特性以及事务的隔离级别
- Git常用命令总结
- redis持久化,主从及数据备份
- JDBC中的Statement和PreparedStatement的区别