<?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>Tue, 24 Jan 2012 01:33:44 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Ralph</title>
		<link>http://www.oraclealchemist.com/news/trick-1-copying-users-the-right-way/comment-page-1/#comment-44487</link>
		<dc:creator>Ralph</dc:creator>
		<pubDate>Tue, 27 Sep 2011 09:09:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.oraclealchemist.com/news/trick-1-copying-users-the-right-way/#comment-44487</guid>
		<description>Found a nice way of getting the termination character (;) appended to each row

exec dbms_metadata.set_transform_param(dbms_metadata.SESSION_TRANSFORM,&#039;SQLTERMINATOR&#039;,TRUE);

Cheers</description>
		<content:encoded><![CDATA[<p>Found a nice way of getting the termination character (;) appended to each row</p>
<p>exec dbms_metadata.set_transform_param(dbms_metadata.SESSION_TRANSFORM,&#8217;SQLTERMINATOR&#8217;,TRUE);</p>
<p>Cheers</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JuniorDBA</title>
		<link>http://www.oraclealchemist.com/news/trick-1-copying-users-the-right-way/comment-page-1/#comment-44486</link>
		<dc:creator>JuniorDBA</dc:creator>
		<pubDate>Sat, 17 Sep 2011 11:15:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.oraclealchemist.com/news/trick-1-copying-users-the-right-way/#comment-44486</guid>
		<description>I figured out the above error. it was because i did not have the select_catalog_role. i tried on the database in which i had this role and worked like wonder.


But in case i have created 3 roles role_A role_B and role_C. then can you please tell me how to get the DDL for these roles. i tried the below

select DBMS_METADATA.GET_GRANTED_DDL(&#039;ROLE&#039;,roleA) from dual;

but did not work. please provide me with the solution at the earliest</description>
		<content:encoded><![CDATA[<p>I figured out the above error. it was because i did not have the select_catalog_role. i tried on the database in which i had this role and worked like wonder.</p>
<p>But in case i have created 3 roles role_A role_B and role_C. then can you please tell me how to get the DDL for these roles. i tried the below</p>
<p>select DBMS_METADATA.GET_GRANTED_DDL(&#8216;ROLE&#8217;,roleA) from dual;</p>
<p>but did not work. please provide me with the solution at the earliest</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JuniorDBA</title>
		<link>http://www.oraclealchemist.com/news/trick-1-copying-users-the-right-way/comment-page-1/#comment-44485</link>
		<dc:creator>JuniorDBA</dc:creator>
		<pubDate>Sat, 17 Sep 2011 09:48:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.oraclealchemist.com/news/trick-1-copying-users-the-right-way/#comment-44485</guid>
		<description>i am getting the below error.
please let me know what i am doing wrong and moreover i want to get a DDL of user created role for ex: my_custom_role. please help

ops1@OESH111:SQL&gt; 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)  2  ;
ERROR:
ORA-31608: specified object of type ROLE_GRANT not found
ORA-06512: at &quot;SYS.DBMS_SYS_ERROR&quot;, line 86
ORA-06512: at &quot;SYS.DBMS_METADATA&quot;, line 2809
ORA-06512: at &quot;SYS.DBMS_METADATA&quot;, line 4450
ORA-06512: at line 1</description>
		<content:encoded><![CDATA[<p>i am getting the below error.<br />
please let me know what i am doing wrong and moreover i want to get a DDL of user created role for ex: my_custom_role. please help</p>
<p>ops1@OESH111:SQL&gt; 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 drp.grantee = dba_users.username)  2  ;<br />
ERROR:<br />
ORA-31608: specified object of type ROLE_GRANT not found<br />
ORA-06512: at &#8220;SYS.DBMS_SYS_ERROR&#8221;, line 86<br />
ORA-06512: at &#8220;SYS.DBMS_METADATA&#8221;, line 2809<br />
ORA-06512: at &#8220;SYS.DBMS_METADATA&#8221;, line 4450<br />
ORA-06512: at line 1</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: santhosh</title>
		<link>http://www.oraclealchemist.com/news/trick-1-copying-users-the-right-way/comment-page-1/#comment-44442</link>
		<dc:creator>santhosh</dc:creator>
		<pubDate>Thu, 21 Apr 2011 04:29:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.oraclealchemist.com/news/trick-1-copying-users-the-right-way/#comment-44442</guid>
		<description>Can one rename a database user (schema)?</description>
		<content:encoded><![CDATA[<p>Can one rename a database user (schema)?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Denis</title>
		<link>http://www.oraclealchemist.com/news/trick-1-copying-users-the-right-way/comment-page-1/#comment-44434</link>
		<dc:creator>Denis</dc:creator>
		<pubDate>Fri, 04 Mar 2011 12:53:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.oraclealchemist.com/news/trick-1-copying-users-the-right-way/#comment-44434</guid>
		<description>like the &#039;exist&#039; subquery idea.</description>
		<content:encoded><![CDATA[<p>like the &#8216;exist&#8217; subquery idea.</p>
]]></content:encoded>
	</item>
	<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>
</channel>
</rss>

