forked from docs/doc-exports
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>
70 lines
10 KiB
HTML
70 lines
10 KiB
HTML
<a name="EN-US_TOPIC_0000001188588988"></a><a name="EN-US_TOPIC_0000001188588988"></a>
|
|
|
|
<h1 class="topictitle1">ALTER SCHEMA</h1>
|
|
<div id="body8662426"><div class="section" id="EN-US_TOPIC_0000001188588988__s27c57ef82c7b4944b09014aac5f06429"><h4 class="sectiontitle">Function</h4><p id="EN-US_TOPIC_0000001188588988__aa294ee5c393c42bf8e5bb6c9ecc9ca18"><strong id="EN-US_TOPIC_0000001188588988__b120552437633552">ALTER SCHEMA</strong> changes the attributes of a schema.</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001188588988__s6c98c237e539413383325a777ed0f75a"><h4 class="sectiontitle">Precautions</h4><p id="EN-US_TOPIC_0000001188588988__p9731315513">Only the owner of a schema, a user granted with the ALTER permission for the schema, or a system administrator has the permission to run the <strong id="EN-US_TOPIC_0000001188588988__b16106824105019">ALTER SCHEMA</strong> statement.</p>
|
|
<p id="EN-US_TOPIC_0000001188588988__p26534795155132">Only the schema owner or the system administrator can change the owner of a schema.</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001188588988__sd37d6b1a796d41e5a806ef20c719825e"><h4 class="sectiontitle">Syntax</h4><ul id="EN-US_TOPIC_0000001188588988__u9270c80303aa4f39a5ac3a520d39eb37"><li id="EN-US_TOPIC_0000001188588988__ld37dafcd0e2440e68823a6264a0dcf16">Rename a schema.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188588988__sc567b311b32641e183678b6221d8d9de"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
|
|
<span class="normal">2</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">ALTER</span><span class="w"> </span><span class="k">SCHEMA</span><span class="w"> </span><span class="k">schema_name</span><span class="w"> </span>
|
|
<span class="w"> </span><span class="k">RENAME</span><span class="w"> </span><span class="k">TO</span><span class="w"> </span><span class="n">new_name</span><span class="p">;</span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
</li><li id="EN-US_TOPIC_0000001188588988__l2ee40ea2c07340848e6e35ace34f7c38">Changes the owner of a schema.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188588988__s626e6a8a81ba4743a520a0fa18b8c31c"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
|
|
<span class="normal">2</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">ALTER</span><span class="w"> </span><span class="k">SCHEMA</span><span class="w"> </span><span class="k">schema_name</span><span class="w"> </span>
|
|
<span class="w"> </span><span class="k">OWNER</span><span class="w"> </span><span class="k">TO</span><span class="w"> </span><span class="n">new_owner</span><span class="p">;</span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
</li></ul>
|
|
</div>
|
|
<ul id="EN-US_TOPIC_0000001188588988__ul1517013256431"><li id="EN-US_TOPIC_0000001188588988__li1939814337438">Changes the storage space limit of the permanent table in the schema.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188588988__screen1039853318437"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
|
|
<span class="normal">2</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">ALTER</span><span class="w"> </span><span class="k">SCHEMA</span><span class="w"> </span><span class="k">schema_name</span><span class="w"> </span>
|
|
<span class="w"> </span><span class="k">WITH</span><span class="w"> </span><span class="n">PERM</span><span class="w"> </span><span class="k">SPACE</span><span class="w"> </span><span class="s1">'space_limit'</span><span class="p">;</span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
</li></ul>
|
|
<div class="section" id="EN-US_TOPIC_0000001188588988__s0191c80e5cb0437cb114af4c634251fd"><h4 class="sectiontitle">Parameter Description</h4><ul id="EN-US_TOPIC_0000001188588988__u6ca2b96c60b54897a301d102ad4062e8"><li id="EN-US_TOPIC_0000001188588988__l61724f6acdf04bef9630a8ea48dd2467"><strong id="EN-US_TOPIC_0000001188588988__a9a231db7d5bd4073a0cb6119f6e44b4d">schema_name</strong><p id="EN-US_TOPIC_0000001188588988__a725f6c325d404a46b66596a24e9d8847">Indicates the name of the current schema.</p>
|
|
<p id="EN-US_TOPIC_0000001188588988__a15a8753e8e2047c5a871350cee902e44">Value range: An existing schema name.</p>
|
|
</li><li id="EN-US_TOPIC_0000001188588988__l0476b0085ebc484dbf3017668b779b4f"><strong id="EN-US_TOPIC_0000001188588988__ac4ff9db7f68a44738f3a3c59a36b3e3c">RENAME TO new_name</strong><p id="EN-US_TOPIC_0000001188588988__a388b728c69524626ace06036adba9823">Renames a schema.</p>
|
|
<p id="EN-US_TOPIC_0000001188588988__aa383d4c09cbf460bb6a70df2ef52fcb6"><strong id="EN-US_TOPIC_0000001188588988__b73337558433552">new_name</strong>: new name of the schema</p>
|
|
<p id="EN-US_TOPIC_0000001188588988__a4f9e8f092a714f708964ec19da00150c">Value range: A string. It must comply with the naming convention.</p>
|
|
</li><li id="EN-US_TOPIC_0000001188588988__lbf7e69c75df24d37ad2922bb9d17e590"><strong id="EN-US_TOPIC_0000001188588988__a00070e9c7e5e42c88e4150bd8912eb28">OWNER TO new_owner</strong><p id="EN-US_TOPIC_0000001188588988__aabfaf2633a9841648c5d8beac87fdf30">Changes the owner of a schema. To do this as a non-administrator, you must be a direct or indirect member of the new owning role, and that role must have CREATE permission in the database.</p>
|
|
<p id="EN-US_TOPIC_0000001188588988__a9c477a4f91884874a57b12961b7e8eac"><strong id="EN-US_TOPIC_0000001188588988__b179298025933552">new_owner</strong>: new owner of a schema</p>
|
|
<p id="EN-US_TOPIC_0000001188588988__a1bea7a4519424218bc266aa70bd22aa2">Value range: An existing user name/role.</p>
|
|
</li><li id="EN-US_TOPIC_0000001188588988__li96469714414"><strong id="EN-US_TOPIC_0000001188588988__b119816191910">WITH PERM SPACE</strong><p id="EN-US_TOPIC_0000001188588988__p3646572440">Changes the storage upper limit of the permanent table in the schema. If a non-administrator user wants to change the storage upper limit, the user must be a direct or indirect member of all new roles, and the member must have the CREATE permission on the database.</p>
|
|
<p id="EN-US_TOPIC_0000001188588988__p364617716442"><strong id="EN-US_TOPIC_0000001188588988__b145469321152">space_limit</strong>: storage upper limit of the permanent table in the new schema.</p>
|
|
<p id="EN-US_TOPIC_0000001188588988__p140915113451">Value range: A string consists of an integer and unit. The unit can be K/M/G/T/P currently. The unit of parsed value is K and cannot exceed the range that can be expressed in 64 bits, which is 1 KB to 9007199254740991 KB.</p>
|
|
</li></ul>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001188588988__s378bf7cf08114c269f8947e5a942a8ee"><h4 class="sectiontitle">Examples</h4><p id="EN-US_TOPIC_0000001188588988__p175001389517">Create an example schema <strong id="EN-US_TOPIC_0000001188588988__b138831711382">schema_test</strong> and user <strong id="EN-US_TOPIC_0000001188588988__b19573151117387">user_a</strong>.</p>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188588988__screen84525252538"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
|
|
<span class="normal">2</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">CREATE</span><span class="w"> </span><span class="k">SCHEMA</span><span class="w"> </span><span class="n">schema_test</span><span class="p">;</span>
|
|
<span class="k">CREATE</span><span class="w"> </span><span class="k">USER</span><span class="w"> </span><span class="n">user_a</span><span class="w"> </span><span class="n">PASSWORD</span><span class="w"> </span><span class="s1">'{Password}'</span><span class="p">;</span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
<p id="EN-US_TOPIC_0000001188588988__p1258115109187">Rename the <strong id="EN-US_TOPIC_0000001188588988__b91746740433552">schema_test</strong> schema as <strong id="EN-US_TOPIC_0000001188588988__b137884696333552">schema_test1</strong>.</p>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188588988__screen156101771814"><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">ALTER</span><span class="w"> </span><span class="k">SCHEMA</span><span class="w"> </span><span class="n">schema_test</span><span class="w"> </span><span class="k">RENAME</span><span class="w"> </span><span class="k">TO</span><span class="w"> </span><span class="n">schema_test1</span><span class="p">;</span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
<p id="EN-US_TOPIC_0000001188588988__p658111091815">Change the owner of <strong id="EN-US_TOPIC_0000001188588988__b191617797033552">schema_test1</strong> to <strong id="EN-US_TOPIC_0000001188588988__b127691020533552">user_a</strong>.</p>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188588988__screen1253017224187"><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">ALTER</span><span class="w"> </span><span class="k">SCHEMA</span><span class="w"> </span><span class="n">schema_test1</span><span class="w"> </span><span class="k">OWNER</span><span class="w"> </span><span class="k">TO</span><span class="w"> </span><span class="n">user_a</span><span class="p">;</span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001188588988__s2665b4986ada44fd9ae772c020546e43"><h4 class="sectiontitle">Helpful Links</h4><p id="EN-US_TOPIC_0000001188588988__a2a911ebe5e3c4aa386d1fe3cb8261b8d"><a href="dws_06_0173.html">CREATE SCHEMA</a>, <a href="dws_06_0204.html">DROP SCHEMA</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>
|
|
|