doc-exports/docs/dws/dev/dws_06_0223.html
Lu, Huayi e6fa411af0 DWS DEV 830.201 version
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>
2024-05-16 07:24:04 +00:00

54 lines
8.2 KiB
HTML

<a name="EN-US_TOPIC_0000001188588986"></a><a name="EN-US_TOPIC_0000001188588986"></a>
<h1 class="topictitle1">SET SESSION AUTHORIZATION</h1>
<div id="body8662426"><div class="section" id="EN-US_TOPIC_0000001188588986__s92d1213dab2e426c9629a0ca0948fdcf"><h4 class="sectiontitle">Function</h4><p id="EN-US_TOPIC_0000001188588986__ab66d09c88e1f46fd8f50fa36640489b6"><strong id="EN-US_TOPIC_0000001188588986__b14329521132013">SET SESSION AUTHORIZATION</strong> sets the session user identifier and the current user identifier of the current SQL session to a specified user.</p>
</div>
<div class="section" id="EN-US_TOPIC_0000001188588986__s2fe2e44356a3445f8991d890710d743c"><h4 class="sectiontitle">Precautions</h4><p id="EN-US_TOPIC_0000001188588986__a56cf542c02e54d32b2d8dd402c2aa6c8">The session identifier can be changed only when the initial session user has the system administrator rights. Otherwise, the system supports the command only when the authenticated user name is specified.</p>
</div>
<div class="section" id="EN-US_TOPIC_0000001188588986__s35387492ff28429fae673879f53fe90c"><h4 class="sectiontitle">Syntax</h4><ul id="EN-US_TOPIC_0000001188588986__uc2bd191b95be4ba38459e9a8c2766e0b"><li id="EN-US_TOPIC_0000001188588986__l9f417de9bc584d739b959a115734e6cc"><strong id="EN-US_TOPIC_0000001188588986__b65237020833443">SET SESSION AUTHORIZATION</strong> sets the session user identifier and the current user identifier of the current session.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188588986__sae6f2b9769c64bd984b9dad7c73107e3"><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">SESSION</span><span class="w"> </span><span class="k">AUTHORIZATION</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_0000001188588986__l70f57a5d94a441bb9d23f5ccc177820f">Reset the identifiers of the session and current users to the initially authenticated user names.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188588986__s0f9dd026a66d473f92af579533aa25b9"><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="err">{</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">SESSION</span><span class="w"> </span><span class="k">AUTHORIZATION</span><span class="w"> </span><span class="k">DEFAULT</span>
<span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="k">RESET</span><span class="w"> </span><span class="k">SESSION</span><span class="w"> </span><span class="k">AUTHORIZATION</span><span class="err">}</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0000001188588986__sc1acf5182ef44721aa02ebb7a5a85163"><h4 class="sectiontitle">Parameter Description</h4><ul id="EN-US_TOPIC_0000001188588986__u26f5766a8612472abcbe6ee7d7ce5b2d"><li id="EN-US_TOPIC_0000001188588986__lf45d400d38e74f57b40be9462069cf22"><strong id="EN-US_TOPIC_0000001188588986__a55640ecac54548fc84a7fb78ef287415">SESSION</strong><p id="EN-US_TOPIC_0000001188588986__ab6026e5e409841b3b33984e90fce1322">Indicates that the specified parameters take effect for the current session.</p>
<p id="EN-US_TOPIC_0000001188588986__a7d8791757d6d4db4a6a425ae95762b74">Value range: A string. It must comply with the naming convention.</p>
</li><li id="EN-US_TOPIC_0000001188588986__l27d11fa92a1448dfbe08b3b2391cddb5"><strong id="EN-US_TOPIC_0000001188588986__a501acc68b5714093a7d91e0c24e2492a">LOCALE</strong><p id="EN-US_TOPIC_0000001188588986__aa496d5bc45cc4f0f935ee2f24f6394da">Indicates that the specified command takes effect only for the current transaction.</p>
</li><li id="EN-US_TOPIC_0000001188588986__l0d92d2e88e3f40b891161bcdfae52179"><strong id="EN-US_TOPIC_0000001188588986__a5d8c95b193c040d69e2a3e00a56892a4">role_name</strong><p id="EN-US_TOPIC_0000001188588986__acb58ba02893c444e9c4311abe840fad6">User name.</p>
<p id="EN-US_TOPIC_0000001188588986__abf19148f51e4411f980e97b03435e5de">Value range: A string. It must comply with the naming convention.</p>
</li><li id="EN-US_TOPIC_0000001188588986__la9a9a2a2a8eb4b8a92f0b61282fcedc0"><strong id="EN-US_TOPIC_0000001188588986__ae8b4515932774d88829b7c27290f28d7">password</strong><p id="EN-US_TOPIC_0000001188588986__a96ed2ae53c7942b38538cc97cd8e7cfd">Specifies the password of a role. It must comply with the password convention.</p>
</li><li id="EN-US_TOPIC_0000001188588986__laaef3acc1cf24472ba063cdd9325f506"><strong id="EN-US_TOPIC_0000001188588986__af04e851cff9d431a902ed7fb1a8c30f0">DEFAULT</strong><p id="EN-US_TOPIC_0000001188588986__a73be460ddb1d453fb0dd879b78993a7d">Reset the identifiers of the session and current users to the initially authenticated user names.</p>
</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0000001188588986__sbed86505ee57440b8fe767cb9ec45c58"><h4 class="sectiontitle">Examples</h4><p id="EN-US_TOPIC_0000001188588986__p240073010561">Set the current user to <strong id="EN-US_TOPIC_0000001188588986__b181857114033443">paul</strong>:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188588986__screen17212144418577"><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">SESSION</span><span class="w"> </span><span class="k">AUTHORIZATION</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_0000001188588986__p164001230135611">View the current session user and the current user:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188588986__screen56941535165717"><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_0000001188588986__p1940013018560">Reset the current user:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001188588986__screen01061727165710"><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">SESSION</span><span class="w"> </span><span class="k">AUTHORIZATION</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
</div>
<div class="section" id="EN-US_TOPIC_0000001188588986__s4732ee77ae784220ab043ba8eabf97ca"><h4 class="sectiontitle">Helpful Links</h4><p id="EN-US_TOPIC_0000001188588986__aa6b251241d6f4af1882d36e5666273dd"><a href="dws_06_0222.html">SET ROLE</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>