当前位置:网站首页>权限不足
权限不足
2022-07-07 18:44:00 【全栈程序员站长】
大家好,又见面了,我是全栈君。
例如以下一个存储过程是dba创建一个表空间、创建一个用户并给这个用户授予权限:
create or replace procedure createTS(tname in varchar2)
is PRAGMA AUTONOMOUS_TRANSACTION; v_createsql varchar2(400); vtbsname varchar2(40); begin vtbsname := tname; v_createsql:=’CREATE TABLESPACE ‘|| vtbsname ||’ DATAFILE ”F:\APP\ADMINISTRATOR\ORADATA\’|| vtbsname ||’.dbf” SIZE 30M AUTOEXTEND ON NEXT 10M’; Dbms_Output.Put_Line(v_createsql); execute immediate v_createsql; v_createsql:=’CREATE USER ‘|| vtbsname ||’ identified by ‘|| vtbsname ||’ default tablespace ‘||vtbsname; Dbms_Output.Put_Line(v_createsql); execute immediate v_createsql; — v_createsql:=’grant ALTER SESSION,CREATE CLUSTER,CREATE DATABASE LINK,CREATE SEQUENCE,CREATE SESSION ,CREATE SYNONYM,CREATE VIEW to ‘|| vtbsname; — v_createsql:=’GRANT CREATE SESSION,CREATE CLUSTER,CREATE INDEXTYPE,CREATE OPERATOR,CREATE PROCEDURE,CREATE SEQUENCE,CREATE TABLE,CREATE TRIGGER,CREATE TYPE,INSERT ANY TABLE,UPDATE ANY TABLE,SELECT ANY TABLE,DELETE ANY TABLE to ‘|| vtbsname; v_createsql:=’GRANT connect,resource to ‘|| vtbsname; Dbms_Output.Put_Line(v_createsql); execute immediate v_createsql;
end createTS;
PROCEDURE CREATETS 已编译
编译通过,例如以下运行
set serveroutput on; execute createTS(‘nk_develop14061342’);
在行 28 上開始运行命令时出错: execute createTS(‘nk_develop14061343’) 错误报告: ORA-01031: 权限不足 ORA-06512: 在 “NK_DEVELOP131021.CREATETS”, line 22 ORA-06512: 在 line 1 01031. 00000 – “insufficient privileges” *Cause: An attempt was made to change the current username or password without the appropriate privilege. This error also occurs if attempting to install a database without the necessary operating system privileges. When Trusted Oracle is configure in DBMS MAC, this error may occur if the user was granted the necessary privilege at a higher label than the current login. *Action: Ask the database administrator to perform the operation or grant the required privileges. For Trusted Oracle users getting this error although granted the the appropriate privilege at a higher label, ask the database administrator to regrant the privilege at the appropriate label. CREATE TABLESPACE nk_develop14061343 DATAFILE ‘F:\APP\ADMINISTRATOR\ORADATA\nk_develop14061343.dbf’ SIZE 30M AUTOEXTEND ON NEXT 10M CREATE USER nk_develop14061343 identified by nk_develop14061343 default tablespace nk_develop14061343 GRANT connect,resource to nk_develop14061343
原因是在运行授予权限之时因为权限不足造成的
找到一个帖子例如以下:http://bbs.csdn.net/topics/360053754
最终找到毛病了,原来是没有权限。尽管当前用户运行语句是有权限的,可是放到存储过程中就必需要显式的赋个权限给当前用户。下面是我找到的资料,贴出来给大家也看一下吧。 ===================== 【IT168 技术文档】我们知道,用户拥有的role权限在存储过程是不可用的。如:
SQL> select * from dba_role_privs where grantee=’SUK’;
GRANTEE GRANTED_ROLE ADMIN_OPTION DEFAULT_ROLE ———— ———— ———— ———— SUK DBA NO YES SUK CONNECT NO YES SUK RESOURCE NO YES
–用户SUK拥有DBA这个role –再创建一个測试存储过程: create or replace procedure p_create_table is begin Execute Immediate ‘create table create_table(id int)’; end p_create_table;
–然后測试 SQL> exec p_create_table;
begin p_create_table; end;
ORA-01031: 权限不足 ORA-06512: 在”SUK.P_CREATE_TABLE”, line 3 ORA-06512: 在line 1
–能够看到。即使拥有DBA role。也不能创建表。role在存储过程中不可用。
–遇到这样的情况,我们一般须要显式进行系统权限。如grant create table to suk; –但这样的方法太麻烦,有时候可能须要进行许多的授权才干运行存储过程 –实际上,oracle给我们提供了在存储过程中使用role权限的方法: –改动存储过程,增加Authid Current_User时存储过程能够使用role权限。 create or replace procedure p_create_table Authid Current_User is begin Execute Immediate ‘create table create_table(id int)’; end p_create_table;
–再尝试运行: SQL> exec p_create_table;
PL/SQL procedure successfully completed
–已经能够运行了。
原来 是要使用调用者权限
因此在创建存储过程时须要增加Authid Current_User当前用户的权限
create or replace procedure createTS(tname in varchar2) Authid Current_User is
要在存储过程里动态创建创建表空间例如以下步骤。 1、须要採用Oracle自治事务。
就在存储过程里增加PRAGMA AUTONOMOUS_TRANSACTION;子句 2、须要显示的分配置创建表空间的权限,否则提示权限不足。 grant alter tablespace to TEST; grant create tablespace to TEST;
感谢网址楼主
http://www.dbfaq.net/FAQ/FixupQL.aspx?QuestionID=112
http://bbs.csdn.net/topics/360053754
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/116452.html原文链接:https://javaforall.cn
边栏推荐
- When easygbs cascades, how to solve the streaming failure and screen jam caused by the restart of the superior platform?
- AADL inspector fault tree safety analysis module
- Nebula importer data import practice
- Don't fall behind! Simple and easy-to-use low code development to quickly build an intelligent management information system
- 目前股票开户安全吗?可以直接网上开户吗。
- 恶魔奶爸 B2 突破语法,完成正统口语练习
- 写了个 Markdown 命令行小工具,希望能提高园友们发文的效率!
- 想杀死某个端口进程,但在服务列表中却找不到,可以之间通过命令行找到这个进程并杀死该进程,减少重启电脑和找到问题根源。
- 目标:不排斥 yaml 语法。争取快速上手
- ERROR: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your
猜你喜欢
Measure the height of the building
Apifox interface integrated management new artifact
目标:不排斥 yaml 语法。争取快速上手
Klocwork 代码静态分析工具
VMWare中虚拟机网络配置
I wrote a markdown command line gadget, hoping to improve the efficiency of sending documents by garden friends!
Cantata9.0 | 全 新 功 能
程序猿赚的那点钱算个P啊!
Don't fall behind! Simple and easy-to-use low code development to quickly build an intelligent management information system
Mysql子查询关键字的使用方式(exists)
随机推荐
I Basic concepts
Implement secondary index with Gaussian redis
Optimization cases of complex factor calculation: deep imbalance, buying and selling pressure index, volatility calculation
C语言 整型 和 浮点型 数据在内存中存储详解(内含原码反码补码,大小端存储等详解)
Phoenix JDBC
ERROR: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your
Don't fall behind! Simple and easy-to-use low code development to quickly build an intelligent management information system
微服务远程Debug,Nocalhost + Rainbond微服务开发第二弹
如何满足医疗设备对安全性和保密性的双重需求?
凌云出海记 | 赛盒&华为云:共助跨境电商行业可持续发展
不落人后!简单好用的低代码开发,快速搭建智慧管理信息系统
【OpenCV 例程200篇】223. 特征提取之多边形拟合(cv.approxPolyDP)
I wrote a markdown command line gadget, hoping to improve the efficiency of sending documents by garden friends!
如何满足医疗设备对安全性和保密性的双重需求?
Micro service remote debug, nocalhost + rainbow micro service development second bullet
【论文阅读】MAPS: Multi-agent Reinforcement Learning-based Portfolio Management System
Write a jump table
C语言多角度帮助你深入理解指针(1. 字符指针2. 数组指针和 指针数组 、数组传参和指针传参3. 函数指针4. 函数指针数组5. 指向函数指针数组的指针6. 回调函数)
备份 TiDB 集群到持久卷
神兵利器——敏感文件发现工具