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>
55 lines
8.6 KiB
HTML
55 lines
8.6 KiB
HTML
<a name="EN-US_TOPIC_0000001188270522"></a><a name="EN-US_TOPIC_0000001188270522"></a>
|
|
|
|
<h1 class="topictitle1">SET ROLE</h1>
|
|
<div id="body8662426"><div class="section" id="EN-US_TOPIC_0000001188270522__s9e57c0e600ec4b7ba752fde19828e058"><h4 class="sectiontitle">Function</h4><p id="EN-US_TOPIC_0000001188270522__ad19d6c9c9c354f8dbd5d0490b95491e5"><strong id="EN-US_TOPIC_0000001188270522__b160985622122130">SET ROLE</strong> sets the current user identifier of the current session.</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001188270522__s4f6b927609a94077be9838b00c437ee5"><h4 class="sectiontitle">Precautions</h4><ul id="EN-US_TOPIC_0000001188270522__u53291aacdf8c422fbd55f8e25f4a2102"><li id="EN-US_TOPIC_0000001188270522__lfa3769bb0e224802a1a8aa2a12bc04be">Users of the current session must be members of specified <strong id="EN-US_TOPIC_0000001188270522__b50394981115024">rolename</strong>, but the system administrator can choose any roles.</li><li id="EN-US_TOPIC_0000001188270522__l5422b84512c34855afccd5193ceeafb5">Executing this command may add rights of a user or restrict rights of a user. If the role of a session user has the <strong id="EN-US_TOPIC_0000001188270522__b13570722183816">INHERITS</strong> attribute, it automatically has all rights of roles that <strong id="EN-US_TOPIC_0000001188270522__b51138664183816">SET ROLE</strong> enables the role to be. In this case, <strong id="EN-US_TOPIC_0000001188270522__b42135007183816">SET ROLE</strong> physically deletes all rights directly granted to session users and rights of its belonging roles and only leaves rights of the specified roles. If the role of the session user has the <strong id="EN-US_TOPIC_0000001188270522__b6643717814377">NOINHERITS</strong> attribute, <strong id="EN-US_TOPIC_0000001188270522__b6106369014377">SET ROLE</strong> deletes rights directly granted to the session user and obtains rights of the specified role.</li></ul>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001188270522__s11af38d8a6f948c5b7c4e89c7972c421"><h4 class="sectiontitle">Syntax</h4><ul id="EN-US_TOPIC_0000001188270522__u9c275b1184da46a0b33e1b47ae7c2e01"><li id="EN-US_TOPIC_0000001188270522__lc51a4f550de14559a5cf81f4d589266f">Set the current user identifier of the current session.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188270522__s13b000803e2942f1af2569d36001cecb"><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">SET</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="k">SESSION</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="k">LOCAL</span><span class="w"> </span><span class="p">]</span><span class="w"> </span><span class="k">ROLE</span><span class="w"> </span><span class="n">role_name</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>
|
|
</li><li id="EN-US_TOPIC_0000001188270522__ld43db4ee40f64a6fbbfb00426e03b708">Reset the current user identifier to that of the current session.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188270522__s6ca13e70e4344dffb225d655e714058e"><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">RESET</span><span class="w"> </span><span class="k">ROLE</span><span class="p">;</span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
</li></ul>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001188270522__s027a6b359e2e414995cb580c9d44fe74"><h4 class="sectiontitle">Parameter Description</h4><ul id="EN-US_TOPIC_0000001188270522__u2430886bffbc4f2eb753ba7f702d3d12"><li id="EN-US_TOPIC_0000001188270522__ldd1198a5f1214051917df69dda2994e9"><strong id="EN-US_TOPIC_0000001188270522__a33b405731c3840538ac533ad83ce7ed4">SESSION</strong><p id="EN-US_TOPIC_0000001188270522__a8b73b28db9ec46699c01e3a3b1805c39">Specifies that the command takes effect only for the current session. This parameter is used by default.</p>
|
|
<p id="EN-US_TOPIC_0000001188270522__a9127fd21f9984ee0a39a33c2dfb76ad5">Value range: A string. It must comply with the naming convention rule.</p>
|
|
</li><li id="EN-US_TOPIC_0000001188270522__l41c3be6f3cdf4878a52a25f4b28584b3"><strong id="EN-US_TOPIC_0000001188270522__a73b13ea729dc485ba3a82ed443de8871">LOCALE</strong><p id="EN-US_TOPIC_0000001188270522__a4258bdc359f34699bd43aeb0845e335e">Indicates that the specified command takes effect only for the current transaction.</p>
|
|
</li><li id="EN-US_TOPIC_0000001188270522__l2694dac1379a491b8dd3eb73bd6110e1"><strong id="EN-US_TOPIC_0000001188270522__a937749c6e1f140eba06ff0b7f6148619">role_name</strong><p id="EN-US_TOPIC_0000001188270522__a9e38e7f798f943bb965ce5594df4403d">Specifies the role name.</p>
|
|
<p id="EN-US_TOPIC_0000001188270522__ac28548f853b24daa838a9dc8041104f4">Value range: A string. It must comply with the naming convention rule.</p>
|
|
</li><li id="EN-US_TOPIC_0000001188270522__lffc54d6c919c4bd7939a99cc115737d7"><strong id="EN-US_TOPIC_0000001188270522__a39bd4b2ad12342d382038f82309aaec4">password</strong><p id="EN-US_TOPIC_0000001188270522__ac229d76d17574c82a5a7e215557f2a94">Specifies the password of a role. It must comply with the password convention.</p>
|
|
</li><li id="EN-US_TOPIC_0000001188270522__lc8eb5dca2ae84372bf31d4a854131564"><strong id="EN-US_TOPIC_0000001188270522__abf52621f7c93405b8188ed95b25f7fd2">RESET ROLE</strong><p id="EN-US_TOPIC_0000001188270522__ae79bd87bb3b04dd2b8226e889d309e6d">Resets the current user identifier.</p>
|
|
</li></ul>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001188270522__sa0f7d9748db646a98c2b90c02303808a"><h4 class="sectiontitle">Examples</h4><p id="EN-US_TOPIC_0000001188270522__p1666012201364">Create a role named <strong id="EN-US_TOPIC_0000001188270522__b523733015154">manager</strong>:</p>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188270522__screen1645250203611"><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">CREATE</span><span class="w"> </span><span class="k">ROLE</span><span class="w"> </span><span class="n">paul</span><span class="w"> </span><span class="n">IDENTIFIED</span><span class="w"> </span><span class="k">BY</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_0000001188270522__p142452456223">Set the current user to <strong id="EN-US_TOPIC_0000001188270522__b137574525137">paul</strong>:</p>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188270522__screen194067173236"><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">SET</span><span class="w"> </span><span class="k">ROLE</span><span class="w"> </span><span class="n">paul</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_0000001188270522__p172453459224">View the current session user and the current user:</p>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188270522__screen134191225192318"><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">SELECT</span><span class="w"> </span><span class="k">SESSION_USER</span><span class="p">,</span><span class="w"> </span><span class="k">CURRENT_USER</span><span class="p">;</span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
<p id="EN-US_TOPIC_0000001188270522__p182441457225">Reset the current user:</p>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188270522__screen10784736102315"><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">RESET</span><span class="w"> </span><span class="k">role</span><span class="p">;</span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
</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>
|
|
|