doc-exports/docs/dws/dev/dws_06_0339.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

131 lines
31 KiB
HTML

<a name="EN-US_TOPIC_0000001446231232"></a><a name="EN-US_TOPIC_0000001446231232"></a>
<h1 class="topictitle1">Access Privilege Inquiry Functions</h1>
<div id="body0000001446231232"><div class="section" id="EN-US_TOPIC_0000001446231232__section1523911540289"><h4 class="sectiontitle">has_any_column_privilege(user, table, privilege)</h4><p id="EN-US_TOPIC_0000001446231232__p102347540287">Description: Queries whether a specified user has permission for any column of table.</p>
<p id="EN-US_TOPIC_0000001446231232__p37907311493">Parameters: <strong id="EN-US_TOPIC_0000001446231232__b131711342423">user</strong> can be declared by name (text type) or OID. <strong id="EN-US_TOPIC_0000001446231232__b688675420211">table</strong> can be declared by name (text type) or OID. <strong id="EN-US_TOPIC_0000001446231232__b9758141110111">privilege</strong> is declared using a text string (text type). The text string can be <strong id="EN-US_TOPIC_0000001446231232__b1325313308114">SELECT</strong>, <strong id="EN-US_TOPIC_0000001446231232__b18572932111120">INSERT</strong>, <strong id="EN-US_TOPIC_0000001446231232__b52051134101114">UPDATE</strong>, <strong id="EN-US_TOPIC_0000001446231232__b9904163519110">REFERENCES</strong>, or multiple permission types separated by commas (,).</p>
<p id="EN-US_TOPIC_0000001446231232__p10235165410286">Return type: <span id="EN-US_TOPIC_0000001446231232__text17234195413286">boolean</span></p>
</div>
<div class="section" id="EN-US_TOPIC_0000001446231232__section12511955293"><h4 class="sectiontitle">has_any_column_privilege(table, privilege)</h4><p id="EN-US_TOPIC_0000001446231232__p1645355291">Description: Queries whether the current user has permission for any column of table.</p>
<p id="EN-US_TOPIC_0000001446231232__p16654142172813">Parameters: <strong id="EN-US_TOPIC_0000001446231232__b33511750171119">table</strong> can be declared by name (text type) or OID. <strong id="EN-US_TOPIC_0000001446231232__b15550956171114">privilege</strong> is declared using a text string (text type). The text string can be <strong id="EN-US_TOPIC_0000001446231232__b65501956101115">SELECT</strong>, <strong id="EN-US_TOPIC_0000001446231232__b7551956141111">INSERT</strong>, <strong id="EN-US_TOPIC_0000001446231232__b155517566111">UPDATE</strong>, <strong id="EN-US_TOPIC_0000001446231232__b3551125661116">REFERENCES</strong>, or multiple permission types separated by commas (,).</p>
<p id="EN-US_TOPIC_0000001446231232__p144585172914">Return type: <span id="EN-US_TOPIC_0000001446231232__text144515562919">boolean</span></p>
<p id="EN-US_TOPIC_0000001446231232__p4451552290"><strong id="EN-US_TOPIC_0000001446231232__b8791210859436">has_any_column_privilege</strong> checks whether a user can access any column of a table in a particular way. Its parameter possibilities are analogous to <strong id="EN-US_TOPIC_0000001446231232__b16970620949436">has_table_privilege</strong>, except that the desired access permission type must be some combination of SELECT, INSERT, UPDATE, or REFERENCES.</p>
<div class="note" id="EN-US_TOPIC_0000001446231232__note24511516296"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001446231232__p16451515296">Note that having any of these permissions at the table level implicitly grants it for each column of the table, so <strong id="EN-US_TOPIC_0000001446231232__b7305184959436">has_any_column_privilege</strong> will always return <strong id="EN-US_TOPIC_0000001446231232__b20624139779436">true</strong> if <strong id="EN-US_TOPIC_0000001446231232__b15749427189436">has_table_privilege</strong> does for the same parameters. But <strong id="EN-US_TOPIC_0000001446231232__b4752988449436">has_any_column_privilege</strong> also succeeds if there is a column-level grant of the permission for at least one column.</p>
</div></div>
</div>
<div class="section" id="EN-US_TOPIC_0000001446231232__section28666817298"><h4 class="sectiontitle">has_column_privilege(user, table, column, privilege)</h4><p id="EN-US_TOPIC_0000001446231232__p68623872915">Description: Queries whether a specified user has permission for column.</p>
<p id="EN-US_TOPIC_0000001446231232__p142671253112814">Parameters: <strong id="EN-US_TOPIC_0000001446231232__b3120165914113">user</strong> can be declared by name (text type) or OID. <strong id="EN-US_TOPIC_0000001446231232__b17184161211">table</strong> can be declared by name (text type) or OID. <strong id="EN-US_TOPIC_0000001446231232__b138372012151212">column</strong> can be declared by a column name (text type) or an attribute number (smallint type). <strong id="EN-US_TOPIC_0000001446231232__b2563102181212">privilege</strong> is declared using a text string. The text string can be <strong id="EN-US_TOPIC_0000001446231232__b356362118124">SELECT</strong>, <strong id="EN-US_TOPIC_0000001446231232__b95637217127">INSERT</strong>, <strong id="EN-US_TOPIC_0000001446231232__b14563172121217">UPDATE</strong>, <strong id="EN-US_TOPIC_0000001446231232__b3564112110123">REFERENCES</strong>, or multiple permission types separated by commas (,).</p>
<p id="EN-US_TOPIC_0000001446231232__p286288192915">Return type: <span id="EN-US_TOPIC_0000001446231232__text108621486295">boolean</span></p>
</div>
<div class="section" id="EN-US_TOPIC_0000001446231232__section8243120296"><h4 class="sectiontitle">has_column_privilege(table, column, privilege)</h4><p id="EN-US_TOPIC_0000001446231232__p1420181262910">Description: Queries whether the current user has permission for column.</p>
<p id="EN-US_TOPIC_0000001446231232__p202269303360">Parameters: <strong id="EN-US_TOPIC_0000001446231232__b28118327125">table</strong> can be declared by name (text type) or OID. <strong id="EN-US_TOPIC_0000001446231232__b18451634131210">column</strong> can be declared by a column name (text type) or an attribute number (smallint type). <strong id="EN-US_TOPIC_0000001446231232__b11925378120">privilege</strong> is declared using a text string. The text string can be <strong id="EN-US_TOPIC_0000001446231232__b1719293741219">SELECT</strong>, <strong id="EN-US_TOPIC_0000001446231232__b16192183710127">INSERT</strong>, <strong id="EN-US_TOPIC_0000001446231232__b17193163713126">UPDATE</strong>, <strong id="EN-US_TOPIC_0000001446231232__b15193163731219">REFERENCES</strong>, or multiple permission types separated by commas (,).</p>
<p id="EN-US_TOPIC_0000001446231232__p42051252913">Return type: <span id="EN-US_TOPIC_0000001446231232__text132051214298">boolean</span></p>
<p id="EN-US_TOPIC_0000001446231232__p4207122292"><strong id="EN-US_TOPIC_0000001446231232__b17895508019436">has_column_privilege</strong> checks whether a user can access a column in a particular way. Its argument possibilities are analogous to <strong id="EN-US_TOPIC_0000001446231232__b3586928809436">has_table_privilege</strong>, with the addition that the column can be specified either by name or attribute number. The desired access permission type must evaluate to some combination of <strong id="EN-US_TOPIC_0000001446231232__b20087615849436">SELECT</strong>, <strong id="EN-US_TOPIC_0000001446231232__b2352198549436">INSERT</strong>, <strong id="EN-US_TOPIC_0000001446231232__b17012967999436">UPDATE</strong>, or <strong id="EN-US_TOPIC_0000001446231232__b5116784999436">REFERENCES</strong>.</p>
<div class="note" id="EN-US_TOPIC_0000001446231232__note12016127292"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001446231232__p13202012182914">Note that having any of these permissions at the table level implicitly grants it for each column of the table.</p>
</div></div>
</div>
<div class="section" id="EN-US_TOPIC_0000001446231232__section193531251162910"><h4 class="sectiontitle">has_database_privilege(user, database, privilege)</h4><p id="EN-US_TOPIC_0000001446231232__p2034735182915">Description: Queries whether a specified user has permission for database.</p>
<p id="EN-US_TOPIC_0000001446231232__p1273103993614">Parameters: <strong id="EN-US_TOPIC_0000001446231232__b626343951215">user</strong> can be declared by name (text type) or OID. <strong id="EN-US_TOPIC_0000001446231232__b618617432123">database</strong> can be declared by name (text type) or OID. <strong id="EN-US_TOPIC_0000001446231232__b143645496123">privilege</strong> is declared using a text string. The text string can be <strong id="EN-US_TOPIC_0000001446231232__b5364949161214">SELECT</strong>, <strong id="EN-US_TOPIC_0000001446231232__b19365194961217">INSERT</strong>, <strong id="EN-US_TOPIC_0000001446231232__b16365949161216">UPDATE</strong>, <strong id="EN-US_TOPIC_0000001446231232__b9365144941218">REFERENCES</strong>, or multiple permission types separated by commas (,).</p>
<p id="EN-US_TOPIC_0000001446231232__p6347185115290">Return type: <span id="EN-US_TOPIC_0000001446231232__text123471151202910">boolean</span></p>
</div>
<div class="section" id="EN-US_TOPIC_0000001446231232__section171591056162920"><h4 class="sectiontitle">has_database_privilege(database, privilege)</h4><p id="EN-US_TOPIC_0000001446231232__p15155205615295">Description: Queries whether the current user has permission for database.</p>
<p id="EN-US_TOPIC_0000001446231232__p11430204744910">Parameters: <strong id="EN-US_TOPIC_0000001446231232__b146181652181218">database</strong> can be declared by name (text type) or OID. <strong id="EN-US_TOPIC_0000001446231232__b84740531320">privilege</strong> is declared using a text string. The text string can be <strong id="EN-US_TOPIC_0000001446231232__b5779610101320">CREATE</strong>, <strong id="EN-US_TOPIC_0000001446231232__b15411912131314">CONNECT</strong>, <strong id="EN-US_TOPIC_0000001446231232__b15652161416139">TEMPORARY</strong>, or <strong id="EN-US_TOPIC_0000001446231232__b1346131711313">TEMP</strong>, or multiple permission types separated by commas (,).</p>
<p id="EN-US_TOPIC_0000001446231232__p19155205692911">Return type: <span id="EN-US_TOPIC_0000001446231232__text19155115672912">boolean</span></p>
<p id="EN-US_TOPIC_0000001446231232__p215519562295">Note: <strong id="EN-US_TOPIC_0000001446231232__b6856322719436">has_database_privilege</strong> checks whether a user can access a database in a particular way. Its argument possibilities are analogous to <strong id="EN-US_TOPIC_0000001446231232__b3570449309436">has_table_privilege</strong>. The desired access permission type must evaluate to some combination of <strong id="EN-US_TOPIC_0000001446231232__b9082608459436">CREATE</strong>, <strong id="EN-US_TOPIC_0000001446231232__b8086387079436">CONNECT</strong>, <strong id="EN-US_TOPIC_0000001446231232__b13961537729436">TEMPORARY</strong>, or <strong id="EN-US_TOPIC_0000001446231232__b7804624409436">TEMP</strong> (which is equivalent to <strong id="EN-US_TOPIC_0000001446231232__b2627330009436">TEMPORARY</strong>).</p>
</div>
<div class="section" id="EN-US_TOPIC_0000001446231232__section0594915183211"><h4 class="sectiontitle">has_foreign_data_wrapper_privilege(user, fdw, privilege)</h4><p id="EN-US_TOPIC_0000001446231232__p2589171519324">Description: Queries whether a specified user has permission for foreign-data wrapper.</p>
<p id="EN-US_TOPIC_0000001446231232__p757515965115">Parameters: <strong id="EN-US_TOPIC_0000001446231232__b3108134141315">user</strong> can be declared by name (text type) or OID. <strong id="EN-US_TOPIC_0000001446231232__b1335555041310">fdw</strong> indicates a foreign-data wrapper, which can be declared by name (text type) or OID. <strong id="EN-US_TOPIC_0000001446231232__b7195115918138">privilege</strong> is declared using a text string, which must be USAGE.</p>
<p id="EN-US_TOPIC_0000001446231232__p10589121512326">The <strong id="EN-US_TOPIC_0000001446231232__b20974115239436">fdw</strong> parameter indicates the name or ID of the foreign data wrapper.</p>
<p id="EN-US_TOPIC_0000001446231232__p1058914153321">Return type: <span id="EN-US_TOPIC_0000001446231232__text1958991533216">boolean</span></p>
</div>
<div class="section" id="EN-US_TOPIC_0000001446231232__section1212161916321"><h4 class="sectiontitle">has_foreign_data_wrapper_privilege(fdw, privilege)</h4><p id="EN-US_TOPIC_0000001446231232__p11814195324">Description: Queries whether the current user has permission for foreign-data wrapper.</p>
<p id="EN-US_TOPIC_0000001446231232__p89691055185116">Parameters: <strong id="EN-US_TOPIC_0000001446231232__b611918581412">fdw</strong> indicates a foreign-data wrapper, which can be declared by name (text type) or OID. <strong id="EN-US_TOPIC_0000001446231232__b116016283141">privilege</strong> is declared using a text string, which must be <strong id="EN-US_TOPIC_0000001446231232__b127749483142">USAGE</strong>.</p>
<p id="EN-US_TOPIC_0000001446231232__p138121918326">Return type: <span id="EN-US_TOPIC_0000001446231232__text18871919320">boolean</span></p>
<p id="EN-US_TOPIC_0000001446231232__p178101919324">Note: <strong id="EN-US_TOPIC_0000001446231232__b13375315659436">has_foreign_data_wrapper_privilege</strong> checks whether a user can access a foreign-data wrapper in a particular way. Its argument possibilities are analogous to <strong id="EN-US_TOPIC_0000001446231232__b17610331229436">has_table_privilege</strong>. The desired access permission type must evaluate to <strong id="EN-US_TOPIC_0000001446231232__b15957843699436">USAGE</strong>.</p>
</div>
<div class="section" id="EN-US_TOPIC_0000001446231232__section41717233328"><h4 class="sectiontitle">has_function_privilege(user, function, privilege)</h4><p id="EN-US_TOPIC_0000001446231232__p1514172373215">Description: Queries whether a specified user has permission for function.</p>
<p id="EN-US_TOPIC_0000001446231232__p53651528155210">Parameters: <strong id="EN-US_TOPIC_0000001446231232__b772632951417">user</strong> can be declared by name (text type) or OID. <strong id="EN-US_TOPIC_0000001446231232__b8591113191412">function</strong> can be declared by name (text type) or OID. <strong id="EN-US_TOPIC_0000001446231232__b2161153891413">privilege</strong> is declared using a text string, which must be <strong id="EN-US_TOPIC_0000001446231232__b9183194601413">EXECUTE</strong>.</p>
<p id="EN-US_TOPIC_0000001446231232__p12140236325">Return type: <span id="EN-US_TOPIC_0000001446231232__text151412231329">boolean</span></p>
</div>
<div class="section" id="EN-US_TOPIC_0000001446231232__section106985262321"><h4 class="sectiontitle">has_function_privilege(function, privilege)</h4><p id="EN-US_TOPIC_0000001446231232__p186954266327">Description: Queries whether the current user has permission for function.</p>
<p id="EN-US_TOPIC_0000001446231232__p1162614544525">Parameters: <strong id="EN-US_TOPIC_0000001446231232__b66141451517">function</strong> can be declared by name (text type) or OID. <strong id="EN-US_TOPIC_0000001446231232__b17106112620154">privilege</strong> is declared using a text string, which must be <strong id="EN-US_TOPIC_0000001446231232__b18106326121517">EXECUTE</strong>.</p>
<p id="EN-US_TOPIC_0000001446231232__p146966263329">Return type: <span id="EN-US_TOPIC_0000001446231232__text46950267327">boolean</span></p>
<p id="EN-US_TOPIC_0000001446231232__p269614262325">Note: <strong id="EN-US_TOPIC_0000001446231232__b15427610109436">has_function_privilege</strong> checks whether a user can access a function in a particular way. Its argument possibilities are analogous to <strong id="EN-US_TOPIC_0000001446231232__b6465653599436">has_table_privilege</strong>. When a function is specified by a text string rather than by OID, the allowed input is the same as that for the <strong id="EN-US_TOPIC_0000001446231232__b9431610899436">regprocedure</strong> data type (see <a href="dws_06_0022.html">Object Identifier Types</a>). The desired access permission type must evaluate to <strong id="EN-US_TOPIC_0000001446231232__b6059264059436">EXECUTE</strong>.</p>
</div>
<div class="section" id="EN-US_TOPIC_0000001446231232__section15916330203210"><h4 class="sectiontitle">has_language_privilege(user, language, privilege)</h4><p id="EN-US_TOPIC_0000001446231232__p29131930133218">Description: Queries whether a specified user has permission for language.</p>
<p id="EN-US_TOPIC_0000001446231232__p11457214532">Parameters: <strong id="EN-US_TOPIC_0000001446231232__b2460192820152">user</strong> can be declared by name (text type) or OID. <strong id="EN-US_TOPIC_0000001446231232__b1853315357155">language</strong> can be declared by name (text type) or OID. <strong id="EN-US_TOPIC_0000001446231232__b206681341131519">privilege</strong> is declared using a text string, which must be <strong id="EN-US_TOPIC_0000001446231232__b26681441111519">USAGE</strong>.</p>
<p id="EN-US_TOPIC_0000001446231232__p20913153053215">Return type: <span id="EN-US_TOPIC_0000001446231232__text0913143018323">boolean</span></p>
</div>
<div class="section" id="EN-US_TOPIC_0000001446231232__section113481334183211"><h4 class="sectiontitle">has_language_privilege(language, privilege)</h4><p id="EN-US_TOPIC_0000001446231232__p8345113403214">Description: Queries whether the current user has permission for language.</p>
<p id="EN-US_TOPIC_0000001446231232__p14152203115536">Parameters: <strong id="EN-US_TOPIC_0000001446231232__b9829743161520">language</strong> can be declared by name (text type) or OID. <strong id="EN-US_TOPIC_0000001446231232__b25031454141517">privilege</strong> is declared using a text string, which must be <strong id="EN-US_TOPIC_0000001446231232__b65031854151518">USAGE</strong>.</p>
<p id="EN-US_TOPIC_0000001446231232__p13345183463216">Return type: <span id="EN-US_TOPIC_0000001446231232__text3345934193215">boolean</span></p>
<p id="EN-US_TOPIC_0000001446231232__p334583417329">Note: <strong id="EN-US_TOPIC_0000001446231232__b6073085839436">has_language_privilege</strong> checks whether a user can access a procedural language in a particular way. Its argument possibilities are analogous to <strong id="EN-US_TOPIC_0000001446231232__b3253426509436">has_table_privilege</strong>. The desired access permission type must evaluate to <strong id="EN-US_TOPIC_0000001446231232__b16323493489436">USAGE</strong>.</p>
</div>
<div class="section" id="EN-US_TOPIC_0000001446231232__section1723837193212"><h4 class="sectiontitle">has_schema_privilege(user, schema, privilege)</h4><p id="EN-US_TOPIC_0000001446231232__p15721203763217">Description: Queries whether a specified user has permission for schema.</p>
<p id="EN-US_TOPIC_0000001446231232__p98401442115611">Parameters: <strong id="EN-US_TOPIC_0000001446231232__b109915817151">user</strong> can be declared by name (text type) or OID. <strong id="EN-US_TOPIC_0000001446231232__b85711010161">schema</strong> can be declared by name (text type) or OID. <strong id="EN-US_TOPIC_0000001446231232__b6291131821613">privilege</strong> is declared using a text string, which can be <strong id="EN-US_TOPIC_0000001446231232__b148911930161617">CREATE</strong>, <strong id="EN-US_TOPIC_0000001446231232__b7678113211616">USAGE</strong>, or multiple permission types separated by commas (,).</p>
<p id="EN-US_TOPIC_0000001446231232__p572114379320">Return type: <span id="EN-US_TOPIC_0000001446231232__text127211637103211">boolean</span></p>
</div>
<div class="section" id="EN-US_TOPIC_0000001446231232__section11979140193214"><h4 class="sectiontitle">has_schema_privilege(schema, privilege)</h4><p id="EN-US_TOPIC_0000001446231232__p1597610407322">Description: Queries whether the current user has permission for schema.</p>
<p id="EN-US_TOPIC_0000001446231232__p238949145615">Parameters: <strong id="EN-US_TOPIC_0000001446231232__b1878620363164">schema</strong> can be declared by name (text type) or OID. <strong id="EN-US_TOPIC_0000001446231232__b69971144191611">privilege</strong> is declared using a text string, which can be <strong id="EN-US_TOPIC_0000001446231232__b18997104481610">CREATE</strong>, <strong id="EN-US_TOPIC_0000001446231232__b7998184421611">USAGE</strong>, or multiple permission types separated by commas (,).</p>
<p id="EN-US_TOPIC_0000001446231232__p3976340193210">Return type: <span id="EN-US_TOPIC_0000001446231232__text15976940173219">boolean</span></p>
<p id="EN-US_TOPIC_0000001446231232__p199761540153219">Note: <strong id="EN-US_TOPIC_0000001446231232__b4813412679436">has_schema_privilege</strong> checks whether a user can access a schema in a particular way. Its argument possibilities are analogous to <strong id="EN-US_TOPIC_0000001446231232__b20020122559436">has_table_privilege</strong>. The desired access permission type must evaluate to some combination of <strong id="EN-US_TOPIC_0000001446231232__b16569532849436">CREATE</strong> or <strong id="EN-US_TOPIC_0000001446231232__b14923400339436">USAGE</strong>.</p>
</div>
<div class="section" id="EN-US_TOPIC_0000001446231232__section17727164483215"><h4 class="sectiontitle">has_server_privilege(user, server, privilege)</h4><p id="EN-US_TOPIC_0000001446231232__p2072684410328">Description: Queries whether a specified user has permission for foreign server.</p>
<p id="EN-US_TOPIC_0000001446231232__p685912825720">Parameters: <strong id="EN-US_TOPIC_0000001446231232__b13421449131619">user</strong> can be declared by name (text type) or OID. <strong id="EN-US_TOPIC_0000001446231232__b1243745220168">server</strong> can be declared by name (text type) or OID. <strong id="EN-US_TOPIC_0000001446231232__b1356910161719">privilege</strong> is declared using a text string, which must be <strong id="EN-US_TOPIC_0000001446231232__b1157010017178">USAGE</strong>.</p>
<p id="EN-US_TOPIC_0000001446231232__p47261144163216">Return type: <span id="EN-US_TOPIC_0000001446231232__text772684483220">boolean</span></p>
</div>
<div class="section" id="EN-US_TOPIC_0000001446231232__section188012477322"><h4 class="sectiontitle">has_server_privilege(server, privilege)</h4><p id="EN-US_TOPIC_0000001446231232__p68781547133215">Description: Queries whether the current user has permission for foreign server.</p>
<p id="EN-US_TOPIC_0000001446231232__p1818983815717">Parameters: <strong id="EN-US_TOPIC_0000001446231232__b16642759178">server</strong> can be declared by name (text type) or OID. <strong id="EN-US_TOPIC_0000001446231232__b1241411291715">privilege</strong> is declared using a text string, which must be <strong id="EN-US_TOPIC_0000001446231232__b12414812131713">USAGE</strong>.</p>
<p id="EN-US_TOPIC_0000001446231232__p168781047153219">Return type: <span id="EN-US_TOPIC_0000001446231232__text1487834703213">boolean</span></p>
<p id="EN-US_TOPIC_0000001446231232__p6878164710326">Note: <strong id="EN-US_TOPIC_0000001446231232__b11033690289436">has_server_privilege</strong> checks whether a user can access a foreign server in a particular way. Its argument possibilities are analogous to <strong id="EN-US_TOPIC_0000001446231232__b835062499436">has_table_privilege</strong>. The desired access permission type must evaluate to <strong id="EN-US_TOPIC_0000001446231232__b16542985429436">USAGE</strong>.</p>
</div>
<div class="section" id="EN-US_TOPIC_0000001446231232__section1127175133218"><h4 class="sectiontitle">has_table_privilege(user, table, privilege)</h4><p id="EN-US_TOPIC_0000001446231232__p19269165115325">Description: Queries whether a specified user has permission for table.</p>
<p id="EN-US_TOPIC_0000001446231232__p15241140165714">Parameters: <strong id="EN-US_TOPIC_0000001446231232__b11467161513178">user</strong> can be declared by name (text type) or OID. <strong id="EN-US_TOPIC_0000001446231232__b03339171176">table</strong> can be declared by name (text type) or OID. <strong id="EN-US_TOPIC_0000001446231232__b171392309170">privilege</strong> is declared using a text string, which can be <strong id="EN-US_TOPIC_0000001446231232__b5148103861720">SELECT</strong>, <strong id="EN-US_TOPIC_0000001446231232__b7166134041714">INSERT</strong>, <strong id="EN-US_TOPIC_0000001446231232__b11547174271711">UPDATE</strong>, <strong id="EN-US_TOPIC_0000001446231232__b1185144141716">DELETE</strong>, <strong id="EN-US_TOPIC_0000001446231232__b28681645191710">TRUNCATE</strong>, <strong id="EN-US_TOPIC_0000001446231232__b17637347101716">REFERENCES</strong>, or <strong id="EN-US_TOPIC_0000001446231232__b1086014921717">TRIGGER</strong>, or multiple permission types separated by commas (,).</p>
<p id="EN-US_TOPIC_0000001446231232__p6269195153210">Return type: <span id="EN-US_TOPIC_0000001446231232__text1726955114327">boolean</span></p>
</div>
<div class="section" id="EN-US_TOPIC_0000001446231232__section19346254103212"><h4 class="sectiontitle">has_table_privilege(table, privilege)</h4><p id="EN-US_TOPIC_0000001446231232__p43455542321">Description: Queries whether the current user has permission for table.</p>
<p id="EN-US_TOPIC_0000001446231232__p13779134235719">Parameters: <strong id="EN-US_TOPIC_0000001446231232__b1232084219189">table</strong> can be declared by name (text type) or OID. <strong id="EN-US_TOPIC_0000001446231232__b1794864341818">privilege</strong> is declared using a text string, which can be <strong id="EN-US_TOPIC_0000001446231232__b9948174351812">SELECT</strong>, <strong id="EN-US_TOPIC_0000001446231232__b39481043131810">INSERT</strong>, <strong id="EN-US_TOPIC_0000001446231232__b1394824341816">UPDATE</strong>, <strong id="EN-US_TOPIC_0000001446231232__b11948124331810">DELETE</strong>, <strong id="EN-US_TOPIC_0000001446231232__b894894317181">TRUNCATE</strong>, <strong id="EN-US_TOPIC_0000001446231232__b394824321813">REFERENCES</strong>, or <strong id="EN-US_TOPIC_0000001446231232__b89491343191813">TRIGGER</strong>, or multiple permission types separated by commas (,).</p>
<p id="EN-US_TOPIC_0000001446231232__p183451454153216">Return type: <span id="EN-US_TOPIC_0000001446231232__text334555493211">boolean</span></p>
<p id="EN-US_TOPIC_0000001446231232__p334510543322"><strong id="EN-US_TOPIC_0000001446231232__b6191887969436">has_table_privilege</strong> checks whether a user can access a table in a particular way. The user can be specified by name, by OID (<strong id="EN-US_TOPIC_0000001446231232__b2863498129436">pg_authid.oid</strong>), <strong id="EN-US_TOPIC_0000001446231232__b15905802729436">public</strong> to indicate the PUBLIC pseudo-role, or if the argument is omitted <strong id="EN-US_TOPIC_0000001446231232__b10241088639436">current_user</strong> is assumed. The table can be specified by name or by OID. When specifying by name, the name can be schema-qualified if necessary. If a text string is used to declare <strong id="EN-US_TOPIC_0000001446231232__b4543101116196">privilege</strong>, you can add <strong id="EN-US_TOPIC_0000001446231232__b4338101641919">WITH GRANT OPTION</strong> to the permission type to test whether the permission has the grant option. When there are multiple permission types, owning one of them will lead to a <strong id="EN-US_TOPIC_0000001446231232__b113591359142415">true</strong> result.</p>
<p id="EN-US_TOPIC_0000001446231232__p1034555463215">Example:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001446231232__screen434665413212"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal"> 1</span>
<span class="normal"> 2</span>
<span class="normal"> 3</span>
<span class="normal"> 4</span>
<span class="normal"> 5</span>
<span class="normal"> 6</span>
<span class="normal"> 7</span>
<span class="normal"> 8</span>
<span class="normal"> 9</span>
<span class="normal">10</span>
<span class="normal">11</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="n">has_table_privilege</span><span class="p">(</span><span class="s1">'tpcds.web_site'</span><span class="p">,</span><span class="w"> </span><span class="s1">'select'</span><span class="p">);</span>
<span class="w"> </span><span class="n">has_table_privilege</span><span class="w"> </span>
<span class="c1">--------------------- </span>
<span class="w"> </span><span class="n">t</span><span class="w"> </span>
<span class="p">(</span><span class="mi">1</span><span class="w"> </span><span class="k">row</span><span class="p">)</span>
<span class="k">SELECT</span><span class="w"> </span><span class="n">has_table_privilege</span><span class="p">(</span><span class="s1">'dbadmin'</span><span class="p">,</span><span class="w"> </span><span class="s1">'tpcds.web_site'</span><span class="p">,</span><span class="w"> </span><span class="s1">'select,INSERT WITH GRANT OPTION '</span><span class="p">);</span>
<span class="w"> </span><span class="n">has_table_privilege</span><span class="w"> </span>
<span class="c1">--------------------- </span>
<span class="w"> </span><span class="n">t</span><span class="w"> </span>
<span class="p">(</span><span class="mi">1</span><span class="w"> </span><span class="k">row</span><span class="p">)</span><span class="w"> </span>
</pre></div></td></tr></table></div>
</div>
</div>
<div class="section" id="EN-US_TOPIC_0000001446231232__section194877810339"><h4 class="sectiontitle">pg_has_role(user, role, privilege)</h4><p id="EN-US_TOPIC_0000001446231232__p7486198193310">Description: Queries whether a specified user has permission for role.</p>
<p id="EN-US_TOPIC_0000001446231232__p16526847135713">Parameters: <strong id="EN-US_TOPIC_0000001446231232__b91938306223">user</strong> can be declared by name (text type) or OID. <strong id="EN-US_TOPIC_0000001446231232__b1390718314221">role</strong> can be declared by name (text type) or OID. <strong id="EN-US_TOPIC_0000001446231232__b12821737192213">privilege</strong> is declared using a text string, which can be <strong id="EN-US_TOPIC_0000001446231232__b0821153792217">MEMBER</strong>, <strong id="EN-US_TOPIC_0000001446231232__b982219378222">USAGE</strong>, or multiple permission types separated by commas (,).</p>
<p id="EN-US_TOPIC_0000001446231232__p8486185336">Return type: <span id="EN-US_TOPIC_0000001446231232__text1448698173315">boolean</span></p>
</div>
<div class="section" id="EN-US_TOPIC_0000001446231232__section20382151218335"><h4 class="sectiontitle">pg_has_role(role, privilege)</h4><p id="EN-US_TOPIC_0000001446231232__p14382012153318">Description: Specifies whether the current user has permission for role.</p>
<p id="EN-US_TOPIC_0000001446231232__p86581149135717">Parameters: <strong id="EN-US_TOPIC_0000001446231232__b141541947142219">role</strong> can be declared by name (text type) or OID. <strong id="EN-US_TOPIC_0000001446231232__b1824145920227">privilege</strong> is declared using a text string, which can be <strong id="EN-US_TOPIC_0000001446231232__b5824185910220">MEMBER</strong>, <strong id="EN-US_TOPIC_0000001446231232__b082445922211">USAGE</strong>, or multiple permission types separated by commas (,).</p>
<p id="EN-US_TOPIC_0000001446231232__p1382212143314">Return type: <span id="EN-US_TOPIC_0000001446231232__text438216129337">boolean</span></p>
<p id="EN-US_TOPIC_0000001446231232__p83821612203311">Note: <strong id="EN-US_TOPIC_0000001446231232__b817634149436">pg_has_role</strong> checks whether a user can access a role in a particular way. Its argument possibilities are analogous to <strong id="EN-US_TOPIC_0000001446231232__b20422990439436">has_table_privilege</strong>, except that <strong id="EN-US_TOPIC_0000001446231232__b9187186899436">public</strong> is not allowed as a user name. The desired access permission type must evaluate to some combination of <strong id="EN-US_TOPIC_0000001446231232__b16764260159436">MEMBER</strong> or <strong id="EN-US_TOPIC_0000001446231232__b20049350449436">USAGE</strong>. <strong id="EN-US_TOPIC_0000001446231232__b20017822829436">MEMBER</strong> denotes direct or indirect membership in the role (that is, the right to do <strong id="EN-US_TOPIC_0000001446231232__b10314905219436">SET ROLE</strong>), while <strong id="EN-US_TOPIC_0000001446231232__b3131748609436">USAGE</strong> denotes the permissions of the role are available without doing <strong id="EN-US_TOPIC_0000001446231232__b4977063649436">SET ROLE</strong>.</p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_06_0051.html">System Information Functions</a></div>
</div>
</div>