NAVEEN

Thursday, August 2, 2018

Collect Database User Metadata information 


Connect to database as administrator and you can use below script to collect any database user metadata information

set echo off
SET LONG 2000000
set pagesize 0
set heading off
set linesize 2000
set feed off
set tab off
set trimout on
set trims on
COL RFILE FORMAT A32000

prompt Create Sequence Skript: Create_user.sql
SET TERMOUT OFF
SET SERVEROUTPUT ON

exec dbms_metadata.set_transform_param(dbms_metadata.session_transform, 'SQLTERMINATOR', true);
spool create_users.sql

SELECT to_char(DBMS_METADATA.GET_DDL('USER', USERNAME)) FROM dba_users where default_tablespace='USERS' and account_status='OPEN' order by username asc;

declare
    no_grant exception;
    role_grants varchar2(255);
    pragma exception_init( no_grant, -31608 );
begin
    for c in (SELECT * FROM dba_users where default_tablespace='USERS' and account_status='OPEN' order by username asc)
    loop
        begin
           role_grants := to_char(DBMS_METADATA.GET_GRANTED_DDL('ROLE_GRANT', c.USERNAME));
        exception when no_grant then
           role_grants := '-- no role grants for user ' || c.username;
        end;
        dbms_output.put_line(role_grants);
    end loop;
end;
/

-- SELECT to_char(DBMS_METADATA.GET_GRANTED_DDL('ROLE_GRANT', USERNAME)) FROM dba_users where default_tablespace='USERS' and account_status='OPEN' order by username asc;

spool off

11 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Great Article… I love to read your articles because your writing style is too good, its is very very helpful for all of us and I never get bored while reading your article because, they are becomes a more and more interesting from the starting lines until the end.

    rpa training in electronic city | rpa training in chennai

    rpa online training | selenium training in training

    ReplyDelete
  3. I really appreciate this post. I’ve been looking all over for this! Thank goodness I found it on Bing. You’ve made my day! Thx again!
    python training Course in chennai
    python training in Bangalore
    Python training institute in kalyan nagar

    ReplyDelete
  4. Thanks for such a great article here. I was searching for something like this for quite a long time and at last I’ve found it on your blog. It was definitely interesting for me to read  about their market situation nowadays.
    devops online training

    aws online training

    data science with python online training

    data science online training

    rpa online training

    ReplyDelete
  5. Thanks for one marvelous posting! I enjoyed reading it; you are a great author. I will make sure to bookmark your blog and may come back someday. I want to encourage that you continue your great posts.

    sap abap training in bangalore

    sap abap courses in bangalore

    sap abap classes in bangalore

    sap abap course syllabus

    best sap abap training

    sap abap training center

    sap abap training institute in bangalore


    ReplyDelete
  6. It was a very good experience,Faculty members are very knowledgeable and cooperative. Specially My trainer teaching more as he focused upon practical rather than theory. All together it was an enlightening and informative course.

    oracle training institutes in bangalore

    oracle training in bangalore

    best oracle training institutes in bangalore

    oracle training course content

    oracle training interview questions

    oracle training & placement in bangalore

    oracle training center in bangalore

    ReplyDelete
  7. Thank you for your post. This is excellent information. It is amazing and wonderful to visit your site.
    Oracle Training in Bangalore

    ReplyDelete
  8. joined in this institution to do Pega training course. I used to attend weekend classes. I am satisfied with the institution as they guided me well. I refer this institution to others also to get better knowledge.My Trainer is the best trainer who guide me very well.Thank you sir

    Oracle training in bangalore

    ReplyDelete
  9. Thanks for sharing amazing information.Gain the knowledge and hands-on experience

    )Oracle training in bangalore, Oracle class in bangalore

    ReplyDelete