<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Trick #1 &#8211; Copying Users the Right Way</title>
	<atom:link href="http://www.oraclealchemist.com/news/trick-1-copying-users-the-right-way/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.oraclealchemist.com/news/trick-1-copying-users-the-right-way/</link>
	<description>Steve Karam's Oracle Blog</description>
	<lastBuildDate>Wed, 27 Jan 2010 06:10:16 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: User-DLL extrahieren &#171; Oracle DBA&#8217;s Weblog</title>
		<link>http://www.oraclealchemist.com/news/trick-1-copying-users-the-right-way/comment-page-1/#comment-44319</link>
		<dc:creator>User-DLL extrahieren &#171; Oracle DBA&#8217;s Weblog</dc:creator>
		<pubDate>Tue, 03 Nov 2009 15:21:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.oraclealchemist.com/news/trick-1-copying-users-the-right-way/#comment-44319</guid>
		<description>[...] Wie man das o.g. Script so ergänzen kann, dass diese Meldung vorher abgefangen werden, erfährt man bspw. hier und hier. [...]</description>
		<content:encoded><![CDATA[<p>[...] Wie man das o.g. Script so ergänzen kann, dass diese Meldung vorher abgefangen werden, erfährt man bspw. hier und hier. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Niall</title>
		<link>http://www.oraclealchemist.com/news/trick-1-copying-users-the-right-way/comment-page-1/#comment-44009</link>
		<dc:creator>Niall</dc:creator>
		<pubDate>Mon, 17 Nov 2008 14:40:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.oraclealchemist.com/news/trick-1-copying-users-the-right-way/#comment-44009</guid>
		<description>Not to come across as picky but are you sure the sql above works on all versions?
I had to do this for an Oracle 9i database and the code I came up with was.
set head off
set pages 0
set long 9999999
spool user_script.sql
SELECT DBMS_METADATA.GET_DDL(&#039;USER&#039;, USERNAME) &#124;&#124; &#039;;&#039; DDL
FROM DBA_USERS;
SELECT DBMS_METADATA.GET_DDL(&#039;ROLE&#039;, role)&#124;&#124;&#039;;&#039; DDL
  FROM dba_roles;
SELECT DBMS_METADATA.GET_GRANTED_DDL(&#039;ROLE_GRANT&#039;, role) &#124;&#124; &#039;;&#039; DDL
FROM role_role_privs;
SELECT DBMS_METADATA.GET_GRANTED_DDL(&#039;SYSTEM_GRANT&#039;, role) &#124;&#124; &#039;;&#039; DDL
FROM role_sys_privs;
SELECT DBMS_METADATA.GET_GRANTED_DDL(&#039;OBJECT_GRANT&#039;, role) &#124;&#124; &#039;;&#039; DDL
FROM role_tab_privs;
spool off;</description>
		<content:encoded><![CDATA[<p>Not to come across as picky but are you sure the sql above works on all versions?<br />
I had to do this for an Oracle 9i database and the code I came up with was.<br />
set head off<br />
set pages 0<br />
set long 9999999<br />
spool user_script.sql<br />
SELECT DBMS_METADATA.GET_DDL(&#8216;USER&#8217;, USERNAME) || &#8216;;&#8217; DDL<br />
FROM DBA_USERS;<br />
SELECT DBMS_METADATA.GET_DDL(&#8216;ROLE&#8217;, role)||&#8217;;&#8217; DDL<br />
  FROM dba_roles;<br />
SELECT DBMS_METADATA.GET_GRANTED_DDL(&#8216;ROLE_GRANT&#8217;, role) || &#8216;;&#8217; DDL<br />
FROM role_role_privs;<br />
SELECT DBMS_METADATA.GET_GRANTED_DDL(&#8216;SYSTEM_GRANT&#8217;, role) || &#8216;;&#8217; DDL<br />
FROM role_sys_privs;<br />
SELECT DBMS_METADATA.GET_GRANTED_DDL(&#8216;OBJECT_GRANT&#8217;, role) || &#8216;;&#8217; DDL<br />
FROM role_tab_privs;<br />
spool off;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Charlie</title>
		<link>http://www.oraclealchemist.com/news/trick-1-copying-users-the-right-way/comment-page-1/#comment-43970</link>
		<dc:creator>Charlie</dc:creator>
		<pubDate>Fri, 05 Sep 2008 09:57:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.oraclealchemist.com/news/trick-1-copying-users-the-right-way/#comment-43970</guid>
		<description>You probably have this by now, but anyhow....

SELECT DBMS_METADATA.GET_granted_DDL(&#039;TABLESPACE_QUOTA&#039;, &#039;SYSTEM&#039;) &#124;&#124; &#039;/&#039; DDL
FROM dual;

As observed earlier, you&#039;ll want to wrap this to avoid the instance where there is no quota for that user.  If you find you can&#039;t get this to work, try using a &#039;real&#039; user rather than SYS or SYSTEM in the function call.</description>
		<content:encoded><![CDATA[<p>You probably have this by now, but anyhow&#8230;.</p>
<p>SELECT DBMS_METADATA.GET_granted_DDL(&#8216;TABLESPACE_QUOTA&#8217;, &#8216;SYSTEM&#8217;) || &#8216;/&#8217; DDL<br />
FROM dual;</p>
<p>As observed earlier, you&#8217;ll want to wrap this to avoid the instance where there is no quota for that user.  If you find you can&#8217;t get this to work, try using a &#8216;real&#8217; user rather than SYS or SYSTEM in the function call.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: m</title>
		<link>http://www.oraclealchemist.com/news/trick-1-copying-users-the-right-way/comment-page-1/#comment-31588</link>
		<dc:creator>m</dc:creator>
		<pubDate>Fri, 12 Oct 2007 02:24:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.oraclealchemist.com/news/trick-1-copying-users-the-right-way/#comment-31588</guid>
		<description>#  Ravinder Says:
#It is helpful to others to add one more proc.
#GET_DEPENDENT_DDL to get the space quota in tablespaces.

Thanks for this tidbit -- I am currently trying to extract it through the GET_DEPENDENT_DDL proc but I couldn&#039;t figure out the correct syntax.  Do you specify the user or the tablespace?  Either way, I couldn&#039;t get it to run:

SQL&gt; select DBMS_METADATA.GET_DEPENDENT_DDL(&#039;TABLESPACE_QUOTA&#039;,&#039;SYSTEM&#039;) FROM DUAL;
ERROR:
ORA-31604: invalid NAME parameter &quot;BASE_OBJECT_NAME&quot; for object type TABLESPACE_QUOTA in function
SET_FILTER
ORA-06512: at &quot;SYS.DBMS_SYS_ERROR&quot;, line 116
ORA-06512: at &quot;SYS.DBMS_METADATA_INT&quot;, line 4676
ORA-06512: at &quot;SYS.DBMS_METADATA_INT&quot;, line 8552
ORA-06512: at &quot;SYS.DBMS_METADATA&quot;, line 2881
ORA-06512: at &quot;SYS.DBMS_METADATA&quot;, line 2757
ORA-06512: at &quot;SYS.DBMS_METADATA&quot;, line 4394
ORA-06512: at line 1

Any thoughts?</description>
		<content:encoded><![CDATA[<p>#  Ravinder Says:<br />
#It is helpful to others to add one more proc.<br />
#GET_DEPENDENT_DDL to get the space quota in tablespaces.</p>
<p>Thanks for this tidbit &#8212; I am currently trying to extract it through the GET_DEPENDENT_DDL proc but I couldn&#8217;t figure out the correct syntax.  Do you specify the user or the tablespace?  Either way, I couldn&#8217;t get it to run:</p>
<p>SQL&gt; select DBMS_METADATA.GET_DEPENDENT_DDL(&#8216;TABLESPACE_QUOTA&#8217;,'SYSTEM&#8217;) FROM DUAL;<br />
ERROR:<br />
ORA-31604: invalid NAME parameter &#8220;BASE_OBJECT_NAME&#8221; for object type TABLESPACE_QUOTA in function<br />
SET_FILTER<br />
ORA-06512: at &#8220;SYS.DBMS_SYS_ERROR&#8221;, line 116<br />
ORA-06512: at &#8220;SYS.DBMS_METADATA_INT&#8221;, line 4676<br />
ORA-06512: at &#8220;SYS.DBMS_METADATA_INT&#8221;, line 8552<br />
ORA-06512: at &#8220;SYS.DBMS_METADATA&#8221;, line 2881<br />
ORA-06512: at &#8220;SYS.DBMS_METADATA&#8221;, line 2757<br />
ORA-06512: at &#8220;SYS.DBMS_METADATA&#8221;, line 4394<br />
ORA-06512: at line 1</p>
<p>Any thoughts?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John G</title>
		<link>http://www.oraclealchemist.com/news/trick-1-copying-users-the-right-way/comment-page-1/#comment-29856</link>
		<dc:creator>John G</dc:creator>
		<pubDate>Thu, 06 Sep 2007 19:29:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.oraclealchemist.com/news/trick-1-copying-users-the-right-way/#comment-29856</guid>
		<description>Still one hangup, setting default role(s) for the users. If there are multiple roles to be set as default for a user they must all be declared in the same ALTER USER statement. The statment can be generated with the function below:

create or replace
FUNCTION f_default_roles(p_usr varchar2) RETURN VARCHAR2 IS
  v_list VARCHAR2(2000);
  v_first boolean;
  CURSOR c_def_roles(v_userid varchar2) IS
    SELECT granted_role
      FROM dba_role_privs
     WHERE grantee = v_userid
       AND default_role = &#039;YES&#039;
     ORDER BY granted_role;
BEGIN
  v_first := true;
  FOR c_rec IN c_def_roles(p_usr)
  LOOP
    if v_first then
      v_list := c_rec.granted_role ;
      v_first := false ;
    else
      v_list := v_list &#124;&#124; &#039;, &#039; &#124;&#124; c_rec.granted_role;
    end if;
  END LOOP;
  if v_first then
    v_list := &#039;-- no default role for &#039; &#124;&#124; p_usr ;
  else 
    v_list := &#039;alter user &#039; &#124;&#124; p_usr &#124;&#124; &#039; default role &#039; &#124;&#124; v_list &#124;&#124; &#039; ;&#039;;
  end if;
  RETURN v_list;
END f_default_roles;</description>
		<content:encoded><![CDATA[<p>Still one hangup, setting default role(s) for the users. If there are multiple roles to be set as default for a user they must all be declared in the same ALTER USER statement. The statment can be generated with the function below:</p>
<p>create or replace<br />
FUNCTION f_default_roles(p_usr varchar2) RETURN VARCHAR2 IS<br />
  v_list VARCHAR2(2000);<br />
  v_first boolean;<br />
  CURSOR c_def_roles(v_userid varchar2) IS<br />
    SELECT granted_role<br />
      FROM dba_role_privs<br />
     WHERE grantee = v_userid<br />
       AND default_role = &#8216;YES&#8217;<br />
     ORDER BY granted_role;<br />
BEGIN<br />
  v_first := true;<br />
  FOR c_rec IN c_def_roles(p_usr)<br />
  LOOP<br />
    if v_first then<br />
      v_list := c_rec.granted_role ;<br />
      v_first := false ;<br />
    else<br />
      v_list := v_list || &#8216;, &#8216; || c_rec.granted_role;<br />
    end if;<br />
  END LOOP;<br />
  if v_first then<br />
    v_list := &#8216;&#8211; no default role for &#8216; || p_usr ;<br />
  else<br />
    v_list := &#8216;alter user &#8216; || p_usr || &#8216; default role &#8216; || v_list || &#8216; ;&#8217;;<br />
  end if;<br />
  RETURN v_list;<br />
END f_default_roles;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave M</title>
		<link>http://www.oraclealchemist.com/news/trick-1-copying-users-the-right-way/comment-page-1/#comment-13064</link>
		<dc:creator>Dave M</dc:creator>
		<pubDate>Sun, 17 Dec 2006 20:50:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.oraclealchemist.com/news/trick-1-copying-users-the-right-way/#comment-13064</guid>
		<description>This will help Bob&#039;s code out and stop the package from issuing errors, where users have no system privlidges. 

SELECT DBMS_METADATA.GET_GRANTED_DDL(&#039;SYSTEM_GRANT&#039;, USERNAME) &#124;&#124; &#039;/&#039; DDL 
FROM DBA_USERS 
where exists (select &#039;x&#039; from dba_role_privs drp, dba_sys_privs dsp 
                            where drp.grantee = dba_users.username
                              and drp.granted_role = dsp.privilege)</description>
		<content:encoded><![CDATA[<p>This will help Bob&#8217;s code out and stop the package from issuing errors, where users have no system privlidges. </p>
<p>SELECT DBMS_METADATA.GET_GRANTED_DDL(&#8216;SYSTEM_GRANT&#8217;, USERNAME) || &#8216;/&#8217; DDL<br />
FROM DBA_USERS<br />
where exists (select &#8216;x&#8217; from dba_role_privs drp, dba_sys_privs dsp<br />
                            where drp.grantee = dba_users.username<br />
                              and drp.granted_role = dsp.privilege)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: The Oracle Alchemist</title>
		<link>http://www.oraclealchemist.com/news/trick-1-copying-users-the-right-way/comment-page-1/#comment-11713</link>
		<dc:creator>The Oracle Alchemist</dc:creator>
		<pubDate>Wed, 29 Nov 2006 02:19:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.oraclealchemist.com/news/trick-1-copying-users-the-right-way/#comment-11713</guid>
		<description>Good call Bob, without this is can make for a painful output script.</description>
		<content:encoded><![CDATA[<p>Good call Bob, without this is can make for a painful output script.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bob Wylie</title>
		<link>http://www.oraclealchemist.com/news/trick-1-copying-users-the-right-way/comment-page-1/#comment-11700</link>
		<dc:creator>Bob Wylie</dc:creator>
		<pubDate>Tue, 28 Nov 2006 21:50:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.oraclealchemist.com/news/trick-1-copying-users-the-right-way/#comment-11700</guid>
		<description>I had to add some qualifiers on the statements so that if a user has not bee issued a grant the procedure does not fail.  Here is my additions:   Note the &#039;exists&#039; statements.

SELECT DBMS_METADATA.GET_GRANTED_DDL(&#039;ROLE_GRANT&#039;, USERNAME) &#124;&#124; &#039;/&#039; DDL 
FROM DBA_USERS where exists (select &#039;x&#039; from dba_role_privs drp where
drp.grantee = dba_users.username)
UNION ALL
SELECT DBMS_METADATA.GET_GRANTED_DDL(&#039;SYSTEM_GRANT&#039;, USERNAME) &#124;&#124; &#039;/&#039; DDL FROM D
BA_USERS where exists (select &#039;x&#039; from dba_role_privs drp where
drp.grantee = dba_users.username)
UNION ALL
SELECT DBMS_METADATA.GET_GRANTED_DDL(&#039;OBJECT_GRANT&#039;, USERNAME) &#124;&#124; &#039;/&#039; DDL FROM D
BA_USERS where exists (select &#039;x&#039; from dba_tab_privs dtp where
dtp.grantee = dba_users.username);</description>
		<content:encoded><![CDATA[<p>I had to add some qualifiers on the statements so that if a user has not bee issued a grant the procedure does not fail.  Here is my additions:   Note the &#8216;exists&#8217; statements.</p>
<p>SELECT DBMS_METADATA.GET_GRANTED_DDL(&#8216;ROLE_GRANT&#8217;, USERNAME) || &#8216;/&#8217; DDL<br />
FROM DBA_USERS where exists (select &#8216;x&#8217; from dba_role_privs drp where<br />
drp.grantee = dba_users.username)<br />
UNION ALL<br />
SELECT DBMS_METADATA.GET_GRANTED_DDL(&#8216;SYSTEM_GRANT&#8217;, USERNAME) || &#8216;/&#8217; DDL FROM D<br />
BA_USERS where exists (select &#8216;x&#8217; from dba_role_privs drp where<br />
drp.grantee = dba_users.username)<br />
UNION ALL<br />
SELECT DBMS_METADATA.GET_GRANTED_DDL(&#8216;OBJECT_GRANT&#8217;, USERNAME) || &#8216;/&#8217; DDL FROM D<br />
BA_USERS where exists (select &#8216;x&#8217; from dba_tab_privs dtp where<br />
dtp.grantee = dba_users.username);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: steve</title>
		<link>http://www.oraclealchemist.com/news/trick-1-copying-users-the-right-way/comment-page-1/#comment-4296</link>
		<dc:creator>steve</dc:creator>
		<pubDate>Fri, 29 Sep 2006 06:11:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.oraclealchemist.com/news/trick-1-copying-users-the-right-way/#comment-4296</guid>
		<description>You&#039;re absolutely right, it helps very much.  Quota information is vital to copy a user verbatim.</description>
		<content:encoded><![CDATA[<p>You&#8217;re absolutely right, it helps very much.  Quota information is vital to copy a user verbatim.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ravinder</title>
		<link>http://www.oraclealchemist.com/news/trick-1-copying-users-the-right-way/comment-page-1/#comment-4242</link>
		<dc:creator>Ravinder</dc:creator>
		<pubDate>Thu, 28 Sep 2006 19:17:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.oraclealchemist.com/news/trick-1-copying-users-the-right-way/#comment-4242</guid>
		<description>Hello ,

It is helpful to others to add one more proc.
GET_DEPENDENT_DDL to get the space quota in tablespaces.

Hope this helps.
Ravinder</description>
		<content:encoded><![CDATA[<p>Hello ,</p>
<p>It is helpful to others to add one more proc.<br />
GET_DEPENDENT_DDL to get the space quota in tablespaces.</p>
<p>Hope this helps.<br />
Ravinder</p>
]]></content:encoded>
	</item>
</channel>
</rss>
