12
返回列表 发新帖
楼主: yang__guo

Oracle系统表问题?

[复制链接]
论坛徽章:
0
11#
 楼主| 发表于 2001-10-9 18:00 | 只看该作者
如果用自己的用户登录的话,应用什么语句可以查看自己对某个表有读写权限?
select * from all_objects where owner = 'OPS$GY'
好象不行耶!

使用道具 举报

回复
论坛徽章:
21
ITPUB元老
日期:2005-02-28 12:57:002012新春纪念徽章
日期:2012-02-13 15:11:182012新春纪念徽章
日期:2012-02-13 15:11:182012新春纪念徽章
日期:2012-02-13 15:11:182012新春纪念徽章
日期:2012-02-13 15:11:18马上有车
日期:2014-02-19 11:55:14马上有房
日期:2014-02-19 11:55:14马上有钱
日期:2014-02-19 11:55:14马上有对象
日期:2014-02-19 11:55:142012新春纪念徽章
日期:2012-02-13 15:11:18
12#
发表于 2001-10-9 18:06 | 只看该作者
user_tab_privs_recd...

使用道具 举报

回复
论坛徽章:
2
授权会员
日期:2005-10-30 17:05:33ITPUB 11周年纪念徽章
日期:2012-10-09 18:03:32
13#
发表于 2001-10-10 02:02 | 只看该作者
Save following script as user_privs, run it under sqlplus.  It will ask you to type user's name, then hit return and it will spool a text file user_user_name_privs.txt.

set linesize 160
set feedback off
set echo off
set trimspool on

col "Username" for a14
col "Rolename" for a14
col "Obj Owner" for a14
col "Obj" for a30
col "Obj Priv" for a10
col "Sys Priv" for a24
col "Granted Role" for a22
col "dummy" noprint
-- This will take out repeating values for "user"
--

accept uname prompt 'Enter the user name:'
-- TTITLE CENTER 'USER PRIVILEDGES'
break on Username skip 1
spool user_&uname._privs.txt
select username "Username",
       owner "Obj Owner",
       table_name "Obj",
       privilege "Obj Priv",
       ' ' "Sys Priv",
       ' ' "Granted Role",
       1 "dummy"
from dba_users u, dba_tab_privs t
where u.username = t.grantee
and u.username not in ('SYS','SYSTEM','DBSNMP')
and t.grantee=upper('&uname')
union
select username,
       ' ',
       ' ',
       ' ',
       privilege,
       ' ',
       2 "dummy"
from dba_users u, dba_sys_privs s
where u.username = s.grantee
and u.username not in ('SYS','SYSTEM','DBSNMP')
and s.grantee=upper('&uname')
union
select username,
       ' ',
       ' ',
       ' ',
       ' ',
       granted_role,
       3 "dummy"
from dba_users u, dba_role_privs r
where u.username = r.grantee
and u.username not in ('SYS','SYSTEM','DBSNMP')
and r.grantee=upper('&uname')
order by 1, 7 desc;
/*
break on role skip 1
-- spool roleprivinventory.txt
set newpage 0
-- TTITLE skip ' ' CENTER 'ROLE PRIVILEDGES'
select role "Rolename",
       owner "Obj Owner",
       table_name "Obj",
       privilege "Obj Priv",
--       ' ' "Sys Priv",
--       ' ' "Granted Role",
       1 "dummy"
from dba_roles u, dba_tab_privs t
where u.role = t.grantee
and t.owner not in ('SYS','SYSTEM','DBSNMP')
and t.grantee=upper('&uname')
order by 1
*/
/
spool off
set feedback on
set pagesize 24
set linesize 100
set echo on

使用道具 举报

回复
论坛徽章:
0
14#
 楼主| 发表于 2001-10-10 10:39 | 只看该作者

谢谢 yanwang ,你这方法的结果跟上面的Select语句的结果一样啊,但是要查看自己对某

我运行后的结果是:
old  11: and t.grantee=upper('&uname')
new  11: and t.grantee=upper('ops$gy')
old  23: and s.grantee=upper('&uname')
new  23: and s.grantee=upper('ops$gy')
old  35: and r.grantee=upper('&uname')
new  35: and r.grantee=upper('ops$gy')

Username       Obj Owner      Obj                            Obj Priv   Sys Priv                 Granted Role
-------------- -------------- ------------------------------ ---------- ------------------------ ----------------------
OPS$GY                                                                  CREATE CLUSTER
                                                                        CREATE PROCEDURE
                                                                        CREATE SEQUENCE
                                                                        CREATE SESSION
                                                                        CREATE SYNONYM
                                                                        CREATE TABLE
                                                                        CREATE TRIGGER
                                                                        CREATE VIEW

DOC>break on role skip 1
DOC>-- spool roleprivinventory.txt
DOC>set newpage 0
DOC>-- TTITLE skip ' ' CENTER 'ROLE PRIVILEDGES'
DOC>select role "Rolename",
DOC>owner "Obj Owner",
DOC>table_name "Obj",
DOC>privilege "Obj Priv",
DOC>-- ' ' "Sys Priv",
DOC>-- ' ' "Granted Role",
DOC>1 "dummy"
DOC>from dba_roles u, dba_tab_privs t
DOC>where u.role = t.grantee
DOC>and t.owner not in ('SYS','SYSTEM','DBSNMP')
DOC>and t.grantee=upper('&uname')
DOC>order by 1
DOC>*/
old  11: and t.grantee=upper('&uname')
new  11: and t.grantee=upper('ops$gy')
old  23: and s.grantee=upper('&uname')
new  23: and s.grantee=upper('ops$gy')
old  35: and r.grantee=upper('&uname')
new  35: and r.grantee=upper('ops$gy')

Username       Obj Owner      Obj                            Obj Priv   Sys Priv                 Granted Role
-------------- -------------- ------------------------------ ---------- ------------------------ ----------------------
OPS$GY                                                                  CREATE CLUSTER
                                                                        CREATE PROCEDURE
                                                                        CREATE SEQUENCE
                                                                        CREATE SESSION
                                                                        CREATE SYNONYM
                                                                        CREATE TABLE
                                                                        CREATE TRIGGER
                                                                        CREATE VIEW

使用道具 举报

回复
论坛徽章:
0
15#
 楼主| 发表于 2001-10-10 10:41 | 只看该作者

chao_ping ,麻烦你说详细点!

最初由 chao_ping 发布
[B]user_tab_privs_recd... [/B]

使用道具 举报

回复
论坛徽章:
2
授权会员
日期:2005-10-30 17:05:33ITPUB 11周年纪念徽章
日期:2012-10-09 18:03:32
16#
发表于 2001-10-11 10:03 | 只看该作者
In order to answer yang_guo's question.  I have written another script.  Hopefully, it will work the way we expected.  The script will not show the tables owned by the user himself.  It can also show the table privileges grant through a role.  Sample output through a role grant like below.

TABLE_OWNE TABLE_NAME              PRIVILEGE  Grant By Role?
----------                 ------------------------------ ---------- --------------
LOAA            ACCOUNT                        DELETE     APPL_DEV
LOAA            ACCOUNT                        INSERT     APPL_DEV
LOAA            ACCOUNT                        SELECT     APPL_DEV
LOAA            ACCOUNT                        UPDATE     APPL_DEV

For direct grant, output will be

TABLE_OWNE  TABLE_NAME       PRIVILEGE  By-Role?
----------    ------------------------------ ---------- ---------
LOAA   ACCOUNT                        DELETE
LOAA   ACCOUNT                        INSERT
LOAA   ACCOUNT                        SELECT
LOAA   ACCOUNT                        UPDATE

Here's the script.  Save it and when you run it, it will ask you the username, then the table name.

col table_owner format a12
col PRIVILEGE format a10
col "Grant By Role?" format a15

set echo off
set feedback off


accept uname prompt 'Enter the user name:'
accept tname prompt 'Enter the table name:'

select
  Owner table_owner,table_name,PRIVILEGE, '      ' "Grant By Role?"
from dba_tab_privs
where         GRANTEE=upper('&uname')
and         TABLE_NAME=upper('&tname')
union
SELECT owner, table_name, privilege,granted_role
FROM ( SELECT granted_role
         FROM dba_role_privs WHERE grantee=UPPER('&uname')
       UNION
       SELECT granted_role
         FROM role_role_privs
         WHERE role in (SELECT granted_role
                            FROM dba_role_privs WHERE grantee=UPPER('&uname')
                           )
        ) roles, dba_tab_privs
WHERE granted_role=grantee
and         table_name=upper('&tname');
/

使用道具 举报

回复
论坛徽章:
0
17#
发表于 2001-10-11 11:42 | 只看该作者
select * from user_tab_privs where table_name='TABLENAME';

另外还要结合 select * from session_privs; 的结果,看该用户是否有下列权限:

SELECT ANY TABLE
INSERT ANY TABLE
UPDATE ANY TABLE
DELETE ANY TABLE

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表