当前位置: 首页 > news >正文

只有select权限,确实也可以for update锁表

一直没注意,赋予查询表的权限在11g之前和12c以后确实有变化了。

https://oracle-base.com/articles/12c/read-object-privilege-12cr1

https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/GRANT.html

如果只赋予查询表权限,12c以后用read,这样才防止用select for update的锁表问题。

[oracle@lnkf ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Tue Sep 16 13:40:40 2025

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> create user j identified by j;

User created.

SQL> grant create session to j;

Grant succeeded.

SQL> conn j/j         
Connected.
SQL> conn jyc/jyc
Connected.
SQL> select table_name from user_tables;

TABLE_NAME
------------------------------
FP
T1
MLOG$_T1
T2
T3
T4
T5
R1
MV_R2
MV_R3
R3

TABLE_NAME
------------------------------
MV_R1
J
RUPD$_T1
SALES
P_TAB
NEWFP
N_TAB

18 rows selected.

SQL> grant select on t1 to j;

Grant succeeded.

SQL> conn j/jy
ERROR:
ORA-01017: invalid username/password; logon denied


Warning: You are no longer connected to ORACLE.
SQL> conn j/j
Connected.
SQL> select * from jyc.t1 for update;

        ID NAME
---------- ------------------------------
         1 a

SQL> ^CEnter password: 

SQL> conn jyc/jyc
Connected.
SQL> grant read on t1 to j;
grant read on t1 to j
              *
ERROR at line 1:
ORA-02224: EXECUTE privilege not allowed for tables


SQL> !oerr ora 2224
02224, 00000, "EXECUTE privilege not allowed for tables"
// *Cause:  An attempt was made to grant or revoke an invalid privilege on
//          a table.
// *Action:  Do not attempt to grant or revoke EXECUTE privilege on tables.
 

[oracle@oracle ~]$ sqlplus jyc/jyc

SQL*Plus: Release 19.0.0.0.0 - Production on Tue Sep 16 14:03:14 2025
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.

Last Successful login time: Fri Aug 30 2024 16:33:23 +08:00

Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

SQL> select table_name from user_tables;

TABLE_NAME
--------------------------------------------------------------------------------
T

SQL> create user j identified by j;

User created.

SQL> grant connect to j;

Grant succeeded.

SQL> grant read on t to j;

Grant succeeded.

SQL> conn j/jy
ERROR:
ORA-01017: invalid username/password; logon denied


Warning: You are no longer connected to ORACLE.
SQL> conn j/j
Connected.
SQL> select * from jyc.t;

  YYYYMMDD
----------
  20240605
  20240701
  20240711
  20240801
  20240809
  20241101
  20241201
  20241202
  20250101

9 rows selected.

SQL> select * from jyc.t for update;
select * from jyc.t for update
                  *
ERROR at line 1:
ORA-01031: insufficient privileges


SQL> 
SQL> 
SQL> 
SQL> conn jyc/jyc     
Connected.
SQL> grant read any table to j;

Grant succeeded.

SQL> create table t1 as select * from dba_objects;

Table created.

SQL> conn j/j
Connected.
SQL> select count(*) from jyc.t1;

  COUNT(*)
----------
     90811

SQL> select * from jyc.t1 for update;
select * from jyc.t1 for update
                  *
ERROR at line 1:
ORA-01031: insufficient privileges


SQL> 

相关参考:https://blog.csdn.net/jnrjian/article/details/131662071


文章转载自:

http://kKoEp0LR.fywqr.cn
http://2rJrbUqk.fywqr.cn
http://N9HlvlK7.fywqr.cn
http://k0XKWJzQ.fywqr.cn
http://AFAfe9mR.fywqr.cn
http://3sdj3OxD.fywqr.cn
http://VUyfGdmk.fywqr.cn
http://Em4ToRww.fywqr.cn
http://Qo28DeiZ.fywqr.cn
http://3fmqcmyD.fywqr.cn
http://Jc4Xt8ik.fywqr.cn
http://5vuWTQrn.fywqr.cn
http://JEnJsnz5.fywqr.cn
http://1iOXOW82.fywqr.cn
http://OHm0WB7S.fywqr.cn
http://p2KsK31w.fywqr.cn
http://r6tQYRL0.fywqr.cn
http://BsPpVleV.fywqr.cn
http://c7jrA8ZY.fywqr.cn
http://hWZXprFG.fywqr.cn
http://sZ7AIgBD.fywqr.cn
http://BXDRGzVu.fywqr.cn
http://HBfCexPB.fywqr.cn
http://eLgJg583.fywqr.cn
http://913cu0UO.fywqr.cn
http://0DHwUslM.fywqr.cn
http://Pmz2JJbo.fywqr.cn
http://MTyMRTGQ.fywqr.cn
http://RAgIqIoq.fywqr.cn
http://ebEVwio5.fywqr.cn
http://www.dtcms.com/a/386765.html

相关文章:

  • HBase核心知识点总结
  • Springboot 使用缓存cache
  • 基于边缘计算的智能管控终端充电站有序充电系统设计与实现 —— 面向实时功率调度需求
  • Nordic BLE智能门锁应用
  • IDEA 连接MySQL数据导出和导入指南
  • 在window下使用visual studio + cmake gui 源码编译 gRPC
  • C# halcon 拼图例子
  • 网络:常见的高速网卡(100Gbps和400Gbps)
  • 第十四届蓝桥杯青少组C++选拔赛[2022.12.18]第二部分编程题(4、充电站)
  • 华为P10plus adb 无线调试USB拔除后立即失效解决
  • openharmony 鸿蒙 下 利用蓝牙API(a2dp模块-高级音频,ble模块-低功耗蓝牙等)完成对蓝牙音响的控制(蓝牙广播)
  • 软考-系统架构设计师 需求工程详细讲解
  • 优化 Coze Studio 依赖管理:镜像源配置与高效实践
  • AIGC入门,从理解通信协议sse与streamhttp开始
  • cuda编程笔记(20)-- 混合精度计算
  • 服务器性能测试的性能指标包括哪些?服务器性能测试工具有哪些?
  • 【面试场景题】跨库数据表关联查询怎么处理
  • 无需复杂正则:SLS 新脱敏函数让隐私保护更简单高效
  • [特殊字符]网络安全学习笔记day1——基本概念,包括域名、DNS、脚本语言、后门、WEB、WEB漏洞
  • 使用ZYNQ芯片和LVGL框架实现用户高刷新UI设计系列教程(第三十讲)
  • Langchain4j开发之AI Service
  • 红帽证书需要什么报考条件
  • Ubuntu 虚拟机 | DPDK 协议栈开发 | 2、DPDK驱动绑定VMWare模拟网卡 + Testpmd发包测试
  • 【高等数学】第十二章 无穷级数——第二节 常数项级数的审敛法
  • 从弱 AI 到通用人工智能(AGI):我们还需要跨越哪些技术鸿沟?
  • Redis 在分布式会话管理中的应用:从单体到微服务的平滑迁移
  • 说说你对闭包的理解? 闭包使⽤场景
  • MySQL 存储过程完整实战手册---一篇吃透 Stored Procedure
  • Leetcode 763. 划分字母区间 贪心
  • 嵌入式系统arm高级系统调试技能-25.cat proc/vmallocinfo文件内容解读,内存异常分析