forked from laiweijian4/doc-exports
Reviewed-by: Hasko, Vladimir <vladimir.hasko@t-systems.com> Co-authored-by: Lu, Huayi <luhuayi@huawei.com> Co-committed-by: Lu, Huayi <luhuayi@huawei.com>
53 lines
14 KiB
HTML
53 lines
14 KiB
HTML
<a name="EN-US_TOPIC_0000001099281248"></a><a name="EN-US_TOPIC_0000001099281248"></a>
|
|
|
|
<h1 class="topictitle1">Deleting Resources</h1>
|
|
<div id="body8662426"><p id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_p8060118">After completing operations in this tutorial, if you no longer need to use the resources created during the operations, you can delete them to avoid resource waste or quota occupation.</p>
|
|
<div class="section" id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_section16262038171510"><h4 class="sectiontitle">Deleting the Foreign Table and Target Table</h4><ol id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_ol667615462149"><li id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_li13105123015615"><span>(Optional) If operations in <a href="dws_04_0215.html#EN-US_TOPIC_0000001146121075__en-us_topic_0000001083024575_en-us_topic_0109259518_en-us_topic_0101477887_section1375535445410">Querying Data After Importing It</a> have been performed, run the following command to delete the target table:</span><p><pre class="screen" id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_screen7106559710">DROP TABLE <em id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_i18249116377">product_info;</em></pre>
|
|
</p></li><li id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_li1678173713610"><span>Run the following command to delete the foreign table:</span><p><pre class="screen" id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_screen745418396710">DROP FOREIGN TABLE <em id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_i215985614154">foreign_</em><em id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_i20159155617154">product_info</em>;</pre>
|
|
</p></li></ol>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_section79551640133718"><a name="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_section79551640133718"></a><a name="en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_section79551640133718"></a><h4 class="sectiontitle">Deleting the Manually Created Foreign Server</h4><p id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_p1123851241819">If operations in <a href="dws_04_0213.html">Manually Creating a Foreign Server</a> have been performed, perform the following steps to delete the foreign server, database, and user:</p>
|
|
<ol id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_ol784216307425"><li id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_li192864493116"><span>Use the client provided by <span id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_ph7194723125711">GaussDB(DWS)</span> to connect to the database where the foreign server resides as the user who created the foreign server.</span><p><p id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_p123651141142812">You can use the <strong id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_b18431155103516">gsql</strong> client to log in to the database in either of the following ways:</p>
|
|
<ul id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_ul1987102122918"><li id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_li286821192916">If you have logged in to the gsql client, run the following command to switch the database and user:<pre class="screen" id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_screen78672118298"><strong id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_b88615211297">\c</strong><strong id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_b198612122916"> </strong><em id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_i38612172914">mydatabase dbuser</em>;</pre>
|
|
<p id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_p393324232911">Enter the password as prompted.</p>
|
|
</li><li id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_li28642119290">If you have logged in to the gsql client, you can run the <strong id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_b842352706114419">\q</strong> command to exit gsql, and run the following command to reconnect to it:<pre class="screen" id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_screen186621132916">gsql -d <em id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_i1486132113294">mydatabase</em> -h <em id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_i1786142142912">192.168.2.30</em> -U <em id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_i1686192142919">dbuser</em> -p 8000 -r</pre>
|
|
<p id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_p13245811296">Enter the password as prompted.</p>
|
|
</li></ul>
|
|
</p></li><li id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_li16842630124215"><span>Delete the manually created foreign server.</span><p><p id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_p96021924141313">Run the following command to delete the server. For details about the syntax, see DROP SERVER.</p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_screen460292411138"><strong id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_b1760202421310">DROP SERVER</strong> <em id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_i14681516142">hdfs_server_8f79ada0_d998_4026_9020_80d6de2692ca</em>;</pre>
|
|
<p id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_p173913112813">The foreign server is deleted if the following information is displayed:</p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_screen194712517287">DROP SERVER</pre>
|
|
<p id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_p2029034143110">View the foreign server.</p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_screen1062415817279">SELECT * FROM pg_foreign_server WHERE srvname='<span id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_ph1627158132719"><em id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_i1162758132714">hdfs_server_8f79ada0_d998_4026_9020_80d6de2692ca</em></span>';</pre>
|
|
<p id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_p182901244318">The server is successfully deleted if the returned result is as follows:</p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_screen1290843319"> srvname | srvowner | srvfdw | srvtype | srvversion | srvacl | srvoptions
|
|
---------+----------+--------+---------+------------+--------+------------
|
|
(0 rows)</pre>
|
|
</p></li><li id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_li1064331316247"><span>Delete the customized database.</span><p><p id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_p9634104918298">Connect to the default database <strong id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_b214510420">gaussdb</strong> through the database client tool provided by <span id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_ph168925005914">GaussDB(DWS)</span>.</p>
|
|
<p id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_p8796721122412">If you have logged in to the database using the <strong id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_b9266143416373">gsql</strong> client, run the following command to switch the database and user:</p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_screen1870343122914">\c gaussdb</pre>
|
|
<p id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_p087074312912">Enter your password as prompted.</p>
|
|
<p id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_p8870174310299">Run the following command to delete the customized database:</p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_screen9870243112917"><strong id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_b88701543142917">DROP </strong><strong id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_b18701543122910">DATABASE</strong> <em id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_i118701143182912">mydatabase</em>;</pre>
|
|
<p id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_p1287044372919">The database is deleted if the following information is displayed:</p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_screen188701443152911">DROP DATABASE</pre>
|
|
</p></li><li id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_li8445514131312"><span>Delete the common user created in this example as the administrator.</span><p><p id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_p29954455811">Connect to the database as a database administrator through the database client tool provided by <span id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_ph17996356135918">GaussDB(DWS)</span>.</p>
|
|
<p id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_p8293122473017">If you have logged in to the database using the <strong id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_b137481047113911">gsql</strong> client, run the following command to switch the database and user:</p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_screen169639381326"><strong id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_b719416174333">\c</strong> gaussdb dbadmin</pre>
|
|
<div class="p" id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_p174451114141315">Run the following command to reclaim the permission for creating foreign servers:<pre class="screen" id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_screen1445111481313"><strong id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_b16445121410134">REVOKE ALL ON</strong> FOREIGN DATA WRAPPER hdfs_fdw <strong id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_b94458142136">FROM</strong> <em id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_i944521461318">dbuser</em>;</pre>
|
|
</div>
|
|
<p id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_p12445131414133">The name of <strong id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_b842352706112833">FOREIGN DATA WRAPPER</strong> must be <strong id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_b842352706112844">hdfs_fdw</strong>. <strong id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_b84235270611292">dbuser</strong> is the username for creating <strong id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_b842352706112940">SERVER</strong>.</p>
|
|
<p id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_p1244513142139">Run the following command to delete the user:</p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_screen344541481319"><strong id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_b34451914101318">DROP USER</strong> <em id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_i1444511421310">dbuser</em>;</pre>
|
|
<p id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_p628972713345">You can run the <b><span class="cmdname" id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_cmdname144471113103516">\du</span></b> command to query for the user and check whether the user has been deleted.</p>
|
|
</p></li></ol>
|
|
<p id="EN-US_TOPIC_0000001099281248__en-us_topic_0000001082926731_en-us_topic_0109259519_en-us_topic_0102427953_p144541155123710"></p>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0210.html">Importing Data from MRS to a Cluster</a></div>
|
|
</div>
|
|
</div>
|
|
|