asked on
ASKER
select distinct user from dba_users a join dba_role_privs b on a.username = b.grantee join dba_tab_privs c on b.granted_role = c.grantee
where c.privilege in('SELECT');
ASKER
"If your application has its own user table, then you have to query that. Nobody could tell you how to do that"You asked for a script for an application user table. We can't give that to you. We don't know your application.
any script for it? I am digging into SQL developer can see if it can help me.
ASKER
ASKER
ASKER
select count(distinct user) from dba_users a join dba_role_privs b on a.username = b.grantee join dba_tab_privs c on b.granted_role = c.grantee where c.privilege in ('UPDATE','INSERT','DELETE')
select * from dba_users a join dba_role_privs b on a.username = b.grantee join dba_tab_privs c on b.granted_role = c.grantee
where c.privilege in ('UPDATE','INSERT','DELETE');
SYS 0 OPEN 03-APR-19 SYSTEM TEMP TEMP 08-MAR-17 DEFAULT SYS_GROUP 11G 12C N PASSWORD N YES Y YES USING_NLS_COMP NO NO SYS DATAPUMP_IMP_FULL_DATABASE YES NO YES YES YES DATAPUMP_IMP_FULL_DATABASE SYS BIN$sYAWrhX5THKRHLtiZZyevw==$0 SYS INSERT NO NO NO TABLE NO
GSMADMIN_INTERNAL 21 EXPIRED & LOCKED 08-MAR-17 08-MAR-17 SYSAUX TEMP TEMP 08-MAR-17 DEFAULT DEFAULT_CONSUMER_GROUP 11G 12C N PASSWORD N YES Y YES USING_NLS_COMP NO NO GSMADMIN_INTERNAL DATAPUMP_IMP_FULL_DATABASE NO NO YES YES YES DATAPUMP_IMP_FULL_DATABASE SYS BIN$sYAWrhX5THKRHLtiZZyevw==$0 SYS INSERT NO NO NO TABLE NO
TONY 177 OPEN 08-APR-19 USERS DEV_IAS_TEMP DEV_IAS_TEMP 10-OCT-18 DEFAULT DEFAULT_CONSUMER_GROUP 11G 12C N PASSWORD N NO 29-OCT-18 11.59.39.000000000 AM ASIA/SHANGHAI N NO USING_NLS_COMP NO NO TONY DATAPUMP_IMP_FULL_DATABASE NO NO YES NO NO DATAPUMP_IMP_FULL_DATABASE SYS BIN$sYAWrhX5THKRHLtiZZyevw==$0 SYS INSERT NO NO NO TABLE NO
SYS 0 OPEN 03-APR-19 SYSTEM TEMP TEMP 08-MAR-17 DEFAULT SYS_GROUP 11G 12C N PASSWORD N YES Y YES USING_NLS_COMP NO NO SYS DATAPUMP_IMP_FULL_DATABASE YES NO YES YES YES DATAPUMP_IMP_FULL_DATABASE SYS BIN$sYAWrhX5THKRHLtiZZyevw==$0 SYS UPDATE NO NO NO TABLE NO
GSMADMIN_INTERNAL 21 EXPIRED & LOCKED 08-MAR-17 08-MAR-17 SYSAUX TEMP TEMP 08-MAR-17 DEFAULT DEFAULT_CONSUMER_GROUP 11G 12C N PASSWORD N YES Y YES USING_NLS_COMP NO NO GSMADMIN_INTERNAL DATAPUMP_IMP_FULL_DATABASE NO NO YES YES YES DATAPUMP_IMP_FULL_DATABASE SYS BIN$sYAWrhX5THKRHLtiZZyevw==$0 SYS UPDATE NO NO NO TABLE NO
TONY 177 OPEN 08-APR-19 USERS DEV_IAS_TEMP DEV_IAS_TEMP 10-OCT-18 DEFAULT DEFAULT_CONSUMER_GROUP 11G 12C N PASSWORD N NO 29-OCT-18 11.59.39.000000000 AM ASIA/SHANGHAI N NO USING_NLS_COMP NO NO TONY DATAPUMP_IMP_FULL_DATABASE NO NO YES NO NO DATAPUMP_IMP_FULL_DATABASE SYS BIN$sYAWrhX5THKRHLtiZZyevw==$0 SYS UPDATE NO NO NO TABLE NO
SYS 0 OPEN 03-APR-19 SYSTEM TEMP TEMP 08-MAR-17 DEFAULT SYS_GROUP 11G 12C N PASSWORD N YES Y YES USING_NLS_COMP NO NO SYS DATAPUMP_IMP_FULL_DATABASE YES NO YES YES YES DATAPUMP_IMP_FULL_DATABASE SYS BIN$p2TBztzdTPavBz3LZWaMfg==$0 SYS INSERT NO NO NO TABLE NO
GSMADMIN_INTERNAL 21 EXPIRED & LOCKED 08-MAR-17 08-MAR-17 SYSAUX TEMP TEMP 08-MAR-17 DEFAULT DEFAULT_CONSUMER_GROUP 11G 12C N PASSWORD N YES Y YES USING_NLS_COMP NO NO GSMADMIN_INTERNAL DATAPUMP_IMP_FULL_DATABASE NO NO YES YES YES DATAPUMP_IMP_FULL_DATABASE SYS BIN$p2TBztzdTPavBz3LZWaMfg==$0 SYS INSERT NO NO NO TABLE NO
TONY 177 OPEN 08-APR-19 USERS DEV_IAS_TEMP DEV_IAS_TEMP 10-OCT-18 DEFAULT DEFAULT_CONSUMER_GROUP 11G 12C N PASSWORD N NO 29-OCT-18 11.59.39.000000000 AM ASIA/SHANGHAI N NO USING_NLS_COMP NO NO TONY DATAPUMP_IMP_FULL_DATABASE NO NO YES NO NO DATAPUMP_IMP_FULL_DATABASE SYS BIN$p2TBztzdTPavBz3LZWaMfg==$0 SYS INSERT NO NO NO TABLE NO
select count (*) from (select user from dba_users a join dba_tab_privs b on a.username = b.grantee
where b.privilege in ('SELECT')
minus
select user from dba_users a join dba_tab_privs b on a.username = b.grantee
where b.privilege in ('UPDATE','INSERT','DELETE'))
SELECT Count(DISTINCT a.username)
FROM dba_users a
JOIN dba_role_privs b
ON a.username = b.grantee
JOIN dba_tab_privs c
ON b.granted_role = c.grantee
WHERE c.privilege IN ( 'UPDATE', 'INSERT', 'DELETE' );
;
Only change is to correct the column that was being selected. Honestly, I have no idea why you couldn't do that yourself. Set up a simple test and it seems to be working for me.
ASKER
select count(distinct username) from dba_users a join dba_role_privs b on a.username = b.grantee join dba_tab_privs c on b.granted_role = c.grantee
where c.privilege in ('UPDATE','INSERT','DELETE');
SELECT Count(DISTINCT a.username)
FROM dba_users a
JOIN dba_role_privs b
ON a.username = b.grantee
JOIN dba_tab_privs c
ON b.granted_role = c.grantee
WHERE c.privilege IN ( 'select' );
ASKER
SELECT Count(DISTINCT a.username)
FROM dba_users a
JOIN dba_role_privs b
ON a.username = b.grantee
JOIN dba_tab_privs c
ON b.granted_role = c.grantee
WHERE c.privilege IN ( 'select' );
Would return no rows in every Oracle database in existence. It would also have nothing to do with read only privileges. If corrected, it would give a count of users that have been granted select privileges through a role. However, they could have other privileges, like insert, update and delete.SQL> create table tab1(col1 char(1));
Table created.
SQL> insert into tab1 values('a');
1 row created.
SQL> commit;
Commit complete.
SQL> create user fred identified by flintstone;
User created.
SQL> grant create session,select any table to fred;
Grant succeeded.
SQL> conn fred/flintstone@orcl
Connected.
SQL> select * from scott.tab1;
a
SQL>
ASKER
SELECT Count(DISTINCT a.username)
FROM dba_users a
JOIN dba_role_privs b
ON a.username = b.grantee
JOIN dba_tab_privs c
ON b.granted_role = c.grantee
WHERE c.privilege NOT IN ( 'UPDATE', 'INSERT', 'DELETE','create', 'drop', 'execute' );
ASKER
ASKER
ASKER
Oracle is an object-relational database management system. It supports a large number of languages and application development frameworks. Its primary languages are SQL, PL/SQL and Java, but it also includes support for C and C++. Oracle also has its own enterprise modules and application server software.
TRUSTED BY
What is the definition of all those things? If these queries are correct, I didn't test them. You should be able to figure out any syntax issues.
I define administrator as anyone who has the DBA role, so:
select count(1) from dba_role_privs where granted_role = 'DBA'
INSERT/UPDATE/DELETE direct grants:
select count(distinct a.user) from dba_users a join dba_tab_privs b on b.grantee = a.username where c.privilege in ('UPDATE','INSERT','DELETE
INSERT/UPDATE/DELETE through a role:
select count(distinct a.user) from dba_users a join dba_role_privs b on a.username = b.grantee join dba_tab_privs c on b.granted_role = c.grantee where c.privilege in ('UPDATE','INSERT','DELETE
You can combine those 2 if you want.
If a user can INSERT/UPDATE/DELETE through a procedure, it is very likely that the privilege is hidden through the code and not able to query through the dictionary.
Read only, i.e. only direct grants are SELECT.
select count(1) from (select a.user from dba_users a join dba_tab_privs b on b.grantee = a.username where c.privilege = 'SELECT' minus select a.user from dba_users a join dba_tab_privs b on b.grantee = a.username where c.privilege in ('UPDATE','INSERT','DELETE
Given the other queries, if you want read only through a role, you should be able to modify the above for that.
What do you mean by security group? Quite possibly you are looking for DBA_PROFILES, but not sure.