doc-exports/docs/dws/dev/dws_06_0214.html
Lu, Huayi e6fa411af0 DWS DEV 830.201 version
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com>
Co-authored-by: Lu, Huayi <luhuayi@huawei.com>
Co-committed-by: Lu, Huayi <luhuayi@huawei.com>
2024-05-16 07:24:04 +00:00

37 lines
8.6 KiB
HTML

<a name="EN-US_TOPIC_0000001233708679"></a><a name="EN-US_TOPIC_0000001233708679"></a>
<h1 class="topictitle1">DROP USER</h1>
<div id="body8662426"><div class="section" id="EN-US_TOPIC_0000001233708679__sf1dc23c18c7e4d70ae11378c09434ef6"><h4 class="sectiontitle">Function</h4><p id="EN-US_TOPIC_0000001233708679__aee6c8d44398242cbb485f76ecf345355">Deleting a user will also delete the schema having the same name as the user.</p>
</div>
<div class="section" id="EN-US_TOPIC_0000001233708679__sad2783b3a56541bcacb9d0a6ee57b6a5"><h4 class="sectiontitle">Precautions</h4><ul id="EN-US_TOPIC_0000001233708679__u96003cf7e59a47b8965caf42c65df6b1"><li id="EN-US_TOPIC_0000001233708679__leb6567da674c4d93a3f9c06279f71b9d"><strong id="EN-US_TOPIC_0000001233708679__b4043243995015">CASCADE</strong> is used to delete objects (excluding databases) that depend on the user. <strong id="EN-US_TOPIC_0000001233708679__b2834763995015">CASCADE</strong> cannot delete locked objects unless the locked objects are unlocked or the processes that lock the objects are killed.</li><li id="EN-US_TOPIC_0000001233708679__la520b400df7a41cd8d6ceddfb04cabdc">When deleting a user in the database, if the object that the user depends on is in another database or the object of the dependent user is another database, you need to manually delete the dependent objects in other databases or delete the dependent database. Then, delete the user. Cross-database cascading deletion cannot be performed.</li><li id="EN-US_TOPIC_0000001233708679__lc36762166075441bab87e82995b4adaf">In a multi-tenant scenario, the service user will also be deleted when you delete a user group. If the specified <strong id="EN-US_TOPIC_0000001233708679__b842352706115734">CASCADE</strong> concatenation is deleted, <strong id="EN-US_TOPIC_0000001233708679__b842352706115413">CASCADE</strong> will be specified upon the deletion of the service user. If you fail to delete a user, an error is reported, and you cannot delete other users either.</li><li id="EN-US_TOPIC_0000001233708679__en-us_topic_0085031986_li13430304141949">If the error table specified by the GDS foreign table created by user A is under the schema of user B, user B cannot be deleted by specifying the <strong id="EN-US_TOPIC_0000001233708679__b7204824121013">CASCADE</strong> keyword in <strong id="EN-US_TOPIC_0000001233708679__b18204132441018">DROP USER</strong>.</li><li id="EN-US_TOPIC_0000001233708679__li821813313614">If a "role is being used by other users" error is displayed when you run <strong id="EN-US_TOPIC_0000001233708679__b18904315125411">DROP USER</strong>, it might be that threads cannot respond to signals in a timely manner during the <strong id="EN-US_TOPIC_0000001233708679__b690811565419">CLEAN CONNECTION</strong> process. As a result, connections are not completely cleared. In this case, you need to run <strong id="EN-US_TOPIC_0000001233708679__b11909191514549">CLEAN CONNECTION</strong> again.</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0000001233708679__sc2c25d4bda8c4a0aa855c4e6c11cfd96"><h4 class="sectiontitle">Syntax</h4><div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001233708679__s8753f24fe4574929bfc89adff181c2cc"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">DROP</span><span class="w"> </span><span class="k">USER</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="k">IF</span><span class="w"> </span><span class="k">EXISTS</span><span class="w"> </span><span class="p">]</span><span class="w"> </span><span class="n">user_name</span><span class="w"> </span><span class="p">[,</span><span class="w"> </span><span class="p">...]</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="k">CASCADE</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="k">RESTRICT</span><span class="w"> </span><span class="p">];</span>
</pre></div></td></tr></table></div>
</div>
</div>
<div class="section" id="EN-US_TOPIC_0000001233708679__se9dc7c333d594ed7a47947f536664d7e"><h4 class="sectiontitle">Parameter Description</h4><ul id="EN-US_TOPIC_0000001233708679__ue8fc8b06575b44f68370320046cd75f4"><li id="EN-US_TOPIC_0000001233708679__l8704ee5944f14e99bc3412d35ba8c22c"><strong id="EN-US_TOPIC_0000001233708679__a065c167fb73f44cd807560bf5c50f4db">IF EXISTS</strong><p id="EN-US_TOPIC_0000001233708679__a46456dc5650e4817a87b7b955009dbba">Sends a notice instead of an error if the specified user does not exist.</p>
</li><li id="EN-US_TOPIC_0000001233708679__l5c2398ebb3fe4094ad541215353dcba5"><strong id="EN-US_TOPIC_0000001233708679__aa6ca0cdc23bb449ea9ec887ec1099f37">user_name</strong><p id="EN-US_TOPIC_0000001233708679__aa6567d00ce4b47a6b78cf28a998af7b8">Specifies the name of a user to be deleted.</p>
<p id="EN-US_TOPIC_0000001233708679__a485199a6506f4b5b8999d6a2fdd593a8">Value range: An existing user name.</p>
</li><li id="EN-US_TOPIC_0000001233708679__l788bfc99e0164ff78eafa04541af2311"><strong id="EN-US_TOPIC_0000001233708679__af61f236d293e47608150f37cf9b190ae">CASCADE | RESTRICT</strong><ul id="EN-US_TOPIC_0000001233708679__u6266ad50c8eb49ad902072429fbf7efe"><li id="EN-US_TOPIC_0000001233708679__l936dd1b2823b4f88bd980d435df1d4fb"><strong id="EN-US_TOPIC_0000001233708679__b55730927233517">CASCADE</strong>: automatically deletes all objects (such as tables) that depend on the user to be deleted. When a user is deleted in CASCADE mode, objects owner by the user and the user's permissions for objects will be deleted.</li><li id="EN-US_TOPIC_0000001233708679__l0de6a81cc4b64017a57a17757173c5ef"><strong id="EN-US_TOPIC_0000001233708679__en-us_topic_0085031986_b842352706132110">RESTRICT</strong>: refuses to delete the user if any objects depend on it. This is the default.</li></ul>
<div class="note" id="EN-US_TOPIC_0000001233708679__note6435822181015"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><div class="p" id="EN-US_TOPIC_0000001233708679__p13791791888">In <span id="EN-US_TOPIC_0000001233708679__text2055139722">GaussDB(DWS)</span>, the <strong id="EN-US_TOPIC_0000001233708679__b162441043124420">postgresql.conf</strong> file contains the <strong id="EN-US_TOPIC_0000001233708679__b32442431443">enable_kill_query</strong> parameter. This parameter affects the action of deleting user objects using <strong id="EN-US_TOPIC_0000001233708679__b4313560595015">CASCADE</strong>.<ul id="EN-US_TOPIC_0000001233708679__ul111157223156"><li id="EN-US_TOPIC_0000001233708679__li18666104961416">If <strong id="EN-US_TOPIC_0000001233708679__b316224805918">enable_kill_query</strong> is <strong id="EN-US_TOPIC_0000001233708679__b101629487598">on</strong> and <strong id="EN-US_TOPIC_0000001233708679__b216214816599">CASCADE</strong> is used to delete user objects, the processes will be automatically killed and the user will be deleted at the same time.</li><li id="EN-US_TOPIC_0000001233708679__li19666114981419">If <strong id="EN-US_TOPIC_0000001233708679__b1758612512016">enable_kill_query</strong> is <strong id="EN-US_TOPIC_0000001233708679__b458625111011">off</strong> and <strong id="EN-US_TOPIC_0000001233708679__b0586135116011">CASCADE</strong> is used to delete user objects, the user will be deleted after the processes are automatically killed.</li></ul>
</div>
</div></div>
</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0000001233708679__sc542703eb3cb43f8ae9d632d3a9f8632"><h4 class="sectiontitle">Example</h4><p id="EN-US_TOPIC_0000001233708679__p65021652191112">Delete user <strong id="EN-US_TOPIC_0000001233708679__b25393685233517">jim</strong>:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001233708679__screen11514465115"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">DROP</span><span class="w"> </span><span class="k">USER</span><span class="w"> </span><span class="n">jim</span><span class="w"> </span><span class="k">CASCADE</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
</div>
<div class="section" id="EN-US_TOPIC_0000001233708679__s20e12635c85c42b5aefa8e0577b83fd3"><h4 class="sectiontitle">Links</h4><p id="EN-US_TOPIC_0000001233708679__a385e1c05db244591beb008d61a8fba20"><a href="dws_06_0149.html">ALTER USER</a>, <a href="dws_06_0186.html">CREATE USER</a></p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_06_0118.html">DDL Syntax</a></div>
</div>
</div>