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>
45 lines
7.8 KiB
HTML
45 lines
7.8 KiB
HTML
<a name="EN-US_TOPIC_0000001510161401"></a><a name="EN-US_TOPIC_0000001510161401"></a>
|
|
|
|
<h1 class="topictitle1">SET ROLE</h1>
|
|
<div id="body8662426"><div class="section" id="EN-US_TOPIC_0000001510161401__s9e57c0e600ec4b7ba752fde19828e058"><h4 class="sectiontitle">Function</h4><p id="EN-US_TOPIC_0000001510161401__ad19d6c9c9c354f8dbd5d0490b95491e5">Sets the current user identifier of the current session.</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001510161401__s4f6b927609a94077be9838b00c437ee5"><h4 class="sectiontitle">Precautions</h4><ul id="EN-US_TOPIC_0000001510161401__u53291aacdf8c422fbd55f8e25f4a2102"><li id="EN-US_TOPIC_0000001510161401__lfa3769bb0e224802a1a8aa2a12bc04be">Users of the current session must be members of specified <strong id="EN-US_TOPIC_0000001510161401__b50394981115024">rolename</strong>, but the system administrator can choose any roles.</li><li id="EN-US_TOPIC_0000001510161401__l5422b84512c34855afccd5193ceeafb5">Executing this command may add rights for a user or take away some of the rights they have. If the role of a session user has the <strong id="EN-US_TOPIC_0000001510161401__b15297164713587">INHERITS</strong> attribute, it is automatically assigned all the rights of the roles assigned by the <strong id="EN-US_TOPIC_0000001510161401__b1729717477586">SET ROLE</strong> command. In this case, <strong id="EN-US_TOPIC_0000001510161401__b22982474581">SET ROLE</strong> physically deletes all rights directly granted to session users and rights of its belonging roles and only the rights of the specified roles remain. If the role of the session user has the <strong id="EN-US_TOPIC_0000001510161401__b6643717814377">NOINHERITS</strong> attribute, <strong id="EN-US_TOPIC_0000001510161401__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_0000001510161401__s11af38d8a6f948c5b7c4e89c7972c421"><h4 class="sectiontitle">Syntax</h4><ul id="EN-US_TOPIC_0000001510161401__u9c275b1184da46a0b33e1b47ae7c2e01"><li id="EN-US_TOPIC_0000001510161401__lc51a4f550de14559a5cf81f4d589266f">Set the current user identifier of the current session.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510161401__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_0000001510161401__ld43db4ee40f64a6fbbfb00426e03b708">Reset the current user identifier to that of the current session.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510161401__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_0000001510161401__s027a6b359e2e414995cb580c9d44fe74"><h4 class="sectiontitle">Parameter Description</h4><ul id="EN-US_TOPIC_0000001510161401__u2430886bffbc4f2eb753ba7f702d3d12"><li id="EN-US_TOPIC_0000001510161401__ldd1198a5f1214051917df69dda2994e9"><strong id="EN-US_TOPIC_0000001510161401__a33b405731c3840538ac533ad83ce7ed4">SESSION</strong><p id="EN-US_TOPIC_0000001510161401__a8b73b28db9ec46699c01e3a3b1805c39">Specifies that the command takes effect only for the current session. This parameter is used by default.</p>
|
|
<p id="EN-US_TOPIC_0000001510161401__a9127fd21f9984ee0a39a33c2dfb76ad5">Value range: a string. It must comply with the naming convention rule.</p>
|
|
</li><li id="EN-US_TOPIC_0000001510161401__l41c3be6f3cdf4878a52a25f4b28584b3"><strong id="EN-US_TOPIC_0000001510161401__a73b13ea729dc485ba3a82ed443de8871">LOCALE</strong><p id="EN-US_TOPIC_0000001510161401__a4258bdc359f34699bd43aeb0845e335e">Indicates that the specified command takes effect only for the current transaction.</p>
|
|
</li><li id="EN-US_TOPIC_0000001510161401__l2694dac1379a491b8dd3eb73bd6110e1"><strong id="EN-US_TOPIC_0000001510161401__a937749c6e1f140eba06ff0b7f6148619">role_name</strong><p id="EN-US_TOPIC_0000001510161401__a9e38e7f798f943bb965ce5594df4403d">Specifies the role name.</p>
|
|
<p id="EN-US_TOPIC_0000001510161401__ac28548f853b24daa838a9dc8041104f4">Value range: a string. It must comply with the naming convention rule.</p>
|
|
</li><li id="EN-US_TOPIC_0000001510161401__lffc54d6c919c4bd7939a99cc115737d7"><strong id="EN-US_TOPIC_0000001510161401__a39bd4b2ad12342d382038f82309aaec4">password</strong><p id="EN-US_TOPIC_0000001510161401__ac229d76d17574c82a5a7e215557f2a94">Specifies the password of a role. It must comply with the password convention.</p>
|
|
</li><li id="EN-US_TOPIC_0000001510161401__lc8eb5dca2ae84372bf31d4a854131564"><strong id="EN-US_TOPIC_0000001510161401__abf52621f7c93405b8188ed95b25f7fd2">RESET ROLE</strong><p id="EN-US_TOPIC_0000001510161401__ae79bd87bb3b04dd2b8226e889d309e6d">Resets the current user identifier.</p>
|
|
</li></ul>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001510161401__sa0f7d9748db646a98c2b90c02303808a"><h4 class="sectiontitle">Examples</h4><p id="EN-US_TOPIC_0000001510161401__p142452456223">Set the current user to <strong id="EN-US_TOPIC_0000001510161401__b137574525137">paul</strong>:</p>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510161401__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_0000001510161401__p172453459224">View the current session user and the current user:</p>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510161401__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_0000001510161401__p182441457225">Reset the current user:</p>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510161401__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>
|
|
|