forked from docs/doc-exports
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com> Co-authored-by: Su, Xiaomeng <suxiaomeng1@huawei.com> Co-committed-by: Su, Xiaomeng <suxiaomeng1@huawei.com>
44 lines
5.8 KiB
HTML
44 lines
5.8 KiB
HTML
<a name="dli_08_0072"></a><a name="dli_08_0072"></a>
|
|
|
|
<h1 class="topictitle1">Deleting a Database</h1>
|
|
<div id="body8662426"><div class="section" id="dli_08_0072__en-us_topic_0114776166_en-us_topic_0093946803_sb4f7c67bcc9e48c8a1cee238ff95ee8a"><h4 class="sectiontitle">Function</h4><p id="dli_08_0072__en-us_topic_0114776166_en-us_topic_0093946803_af7332f86aa314eb592b007d739e64928">This statement is used to delete a database.</p>
|
|
</div>
|
|
<div class="section" id="dli_08_0072__en-us_topic_0114776166_en-us_topic_0093946803_s31fb77ecb4944d48b8e1a1f336352a75"><h4 class="sectiontitle">Syntax</h4><div class="codecoloring" codetype="Sql" id="dli_08_0072__en-us_topic_0114776166_screen156871325978"><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="p">[</span><span class="k">DATABASE</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="k">SCHEMA</span><span class="p">]</span><span class="w"> </span><span class="p">[</span><span class="k">IF</span><span class="w"> </span><span class="k">EXISTS</span><span class="p">]</span><span class="w"> </span><span class="n">db_name</span><span class="w"> </span><span class="p">[</span><span class="k">RESTRICT</span><span class="o">|</span><span class="k">CASCADE</span><span class="p">];</span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
</div>
|
|
<div class="section" id="dli_08_0072__en-us_topic_0114776166_en-us_topic_0093946803_s1abdf21b005747b3874f626419bd591b"><h4 class="sectiontitle">Keywords</h4><p id="dli_08_0072__en-us_topic_0114776166_en-us_topic_0093946803_p5043518695416"><strong id="dli_08_0072__en-us_topic_0114776166_b1454744510429">IF EXISTS</strong>: Prevents system errors if the database to be deleted does not exist.</p>
|
|
</div>
|
|
<div class="section" id="dli_08_0072__en-us_topic_0114776166_en-us_topic_0093946803_sfc216fe9b4ca4acbae65fd45de064533"><h4 class="sectiontitle">Precautions</h4><ul id="dli_08_0072__ul102204420463"><li id="dli_08_0072__li142274444614"><strong id="dli_08_0072__en-us_topic_0114776166_en-us_topic_0093946803_b842352706144955">DATABASE</strong> and <strong id="dli_08_0072__en-us_topic_0114776166_en-us_topic_0093946803_b842352706144958">SCHEMA</strong> can be used interchangeably. You are advised to use <strong id="dli_08_0072__en-us_topic_0114776166_en-us_topic_0093946803_b84235270614503">DATABASE</strong>.</li><li id="dli_08_0072__li20221644134619"><strong id="dli_08_0072__b10272132419181">RESTRICT</strong>: If the database is not empty (tables exist), an error is reported and the <strong id="dli_08_0072__b1618409187">DROP</strong> operation fails. <strong id="dli_08_0072__b7173950161811">RESTRICT</strong> is the default logic.</li><li id="dli_08_0072__li12334434611"><strong id="dli_08_0072__b31571213152213">CASCADE</strong>: Even if the database is not empty (tables exist), the <strong id="dli_08_0072__b91929173244">DROP</strong> will delete all the tables in the database. Therefore, exercise caution when using this function.</li></ul>
|
|
</div>
|
|
<div class="section" id="dli_08_0072__en-us_topic_0114776170_section1130610201331"><h4 class="sectiontitle">Parameters</h4>
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="dli_08_0072__en-us_topic_0114776170_table137579239220" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Parameter</caption><thead align="left"><tr id="dli_08_0072__en-us_topic_0114776170_row17564232219"><th align="left" class="cellrowborder" valign="top" width="21.3%" id="mcps1.3.5.2.2.3.1.1"><p id="dli_08_0072__en-us_topic_0114776170_p3756152318220">Parameter</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="78.7%" id="mcps1.3.5.2.2.3.1.2"><p id="dli_08_0072__en-us_topic_0114776170_p167561023629">Description</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="dli_08_0072__en-us_topic_0114776170_row1375611231219"><td class="cellrowborder" valign="top" width="21.3%" headers="mcps1.3.5.2.2.3.1.1 "><p id="dli_08_0072__en-us_topic_0114776170_p107564232216">db_name</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="78.7%" headers="mcps1.3.5.2.2.3.1.2 "><p id="dli_08_0072__en-us_topic_0114776170_p1575614231121">Database name, which consists of letters, digits, and underscores (_). The value cannot contain only digits or start with a digit or underscore (_).</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="dli_08_0072__en-us_topic_0114776166_en-us_topic_0093946803_sdaf96bd7f7ca490b984b832d0762188a"><h4 class="sectiontitle">Example</h4><ol id="dli_08_0072__ol17435141010615"><li id="dli_08_0072__li84357101468">Create a database, for example, <strong id="dli_08_0072__b49551338123410">testdb</strong>, by referring to <a href="dli_08_0071.html#dli_08_0071__en-us_topic_0114776165_en-us_topic_0093946907_se85f897bfc724638829c13a14150cab6">Example</a>.</li><li id="dli_08_0072__li935412569613">Run the following statement to delete database <strong id="dli_08_0072__en-us_topic_0114776166_en-us_topic_0093946803_b84235270616148">testdb</strong> if it exists:<div class="codecoloring" codetype="Sql" id="dli_08_0072__en-us_topic_0114776166_screen820514582072"><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">DATABASE</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="n">testdb</span><span class="p">;</span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
</li></ol>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="dli_08_0070.html">Databases</a></div>
|
|
</div>
|
|
</div>
|
|
|