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>
43 lines
9.5 KiB
HTML
43 lines
9.5 KiB
HTML
<a name="EN-US_TOPIC_0000001188270540"></a><a name="EN-US_TOPIC_0000001188270540"></a>
|
|
|
|
<h1 class="topictitle1">Data Masking Functions</h1>
|
|
<div id="body1579576763720"><p id="EN-US_TOPIC_0000001188270540__p2023316489113">Data masking functions are used to mask and protect sensitive data. Generally, you are advised to bind these functions to the columns to be redacted based on the data masking syntax, rather than use them directly on query statements.</p>
|
|
<div class="section" id="EN-US_TOPIC_0000001188270540__section129521940191712"><h4 class="sectiontitle">mask_none(column_name)</h4><p id="EN-US_TOPIC_0000001188270540__p4375225133715">Description: Masks no data (for internal tests only).</p>
|
|
<p id="EN-US_TOPIC_0000001188270540__p2783144941718">Return type: same as <strong id="EN-US_TOPIC_0000001188270540__b190555489294325">column_name</strong></p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001188270540__section881153818170"><h4 class="sectiontitle">mask_full(column_name)</h4><p id="EN-US_TOPIC_0000001188270540__p1631317034114">Description: Replaces all data with a fixed value. The fixed value varies depending on the data type of the redacted column.</p>
|
|
<p id="EN-US_TOPIC_0000001188270540__p4170155710174">Return type: same as <strong id="EN-US_TOPIC_0000001188270540__b12926165714612">column_name</strong></p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001188270540__section147791736131719"><h4 class="sectiontitle">mask_partial(column_name, mask_digital, mask_from[, mask_to])</h4><p id="EN-US_TOPIC_0000001188270540__p769914223582">Description: Replaces the digits from the <strong id="EN-US_TOPIC_0000001188270540__b1589116223819">mask_from</strong> to <strong id="EN-US_TOPIC_0000001188270540__b47902361882">mask_to</strong> position in a number with the digit specified by <strong id="EN-US_TOPIC_0000001188270540__b774091196">mask_digital</strong>. The default value of <strong id="EN-US_TOPIC_0000001188270540__b206241114365">mask_to</strong> can be used, which indicates that the digits from the <strong id="EN-US_TOPIC_0000001188270540__b13669546163715">mask_from</strong> position to the end of the number are replaced. <strong id="EN-US_TOPIC_0000001188270540__b16712204011383">mask_digital</strong> can only be a digit from 0 to 9.</p>
|
|
<p id="EN-US_TOPIC_0000001188270540__p892717119188">Return type: same as <strong id="EN-US_TOPIC_0000001188270540__b14762174114318">column_name</strong></p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001188270540__section6528433181716"><h4 class="sectiontitle">mask_partial(column_name [, input_format, output_format], mask_char, mask_from[, mask_to])</h4><p id="EN-US_TOPIC_0000001188270540__p1721450184820">Description: Replaces the digits from the <strong id="EN-US_TOPIC_0000001188270540__b166611320518">mask_from</strong> to <strong id="EN-US_TOPIC_0000001188270540__b1466115305111">mask_to</strong> position in a string with the character specified by <strong id="EN-US_TOPIC_0000001188270540__b187733675010">mask_char</strong> based on the given input and output formats.</p>
|
|
<p id="EN-US_TOPIC_0000001188270540__p44461840292">Parameter description:</p>
|
|
<ul id="EN-US_TOPIC_0000001188270540__ul396918861012"><li id="EN-US_TOPIC_0000001188270540__li11666754690">input_format<p id="EN-US_TOPIC_0000001188270540__p114111041712"><a name="EN-US_TOPIC_0000001188270540__li11666754690"></a><a name="li11666754690"></a>The input format is a character string of V and F, whose length is the same as that of the data in the redacted column. Characters in positions corresponding to V may be masked, and characters in positions corresponding to F are skipped. The V character string specifies which characters are to be masked. The input and output formats apply to data with a fixed length, such as bank card numbers, ID card numbers, and phone numbers.</p>
|
|
</li><li id="EN-US_TOPIC_0000001188270540__li18125122115102">output_format<p id="EN-US_TOPIC_0000001188270540__p161776620139"><a name="EN-US_TOPIC_0000001188270540__li18125122115102"></a><a name="li18125122115102"></a>The output format is a character string of V and any other character, whose length is the same as that of the data in the redacted column. V characters correspond to those in the <strong id="EN-US_TOPIC_0000001188270540__b11917358165110">input_format</strong>, and other characters correspond to the F characters in the <strong id="EN-US_TOPIC_0000001188270540__b8641163095217">input_format</strong>. </p>
|
|
<p id="EN-US_TOPIC_0000001188270540__p664732716174">For parameters <strong id="EN-US_TOPIC_0000001188270540__b1022716456312">input_format</strong> and <strong id="EN-US_TOPIC_0000001188270540__b544317499312">output_format</strong>, you can use their default values or set them to <strong id="EN-US_TOPIC_0000001188270540__b546617610421">""</strong>. In this case, there is no requirement for the input or output format, and the whole string will be masked.</p>
|
|
</li><li id="EN-US_TOPIC_0000001188270540__li883632415101">mask_char<p id="EN-US_TOPIC_0000001188270540__p113461522163"><a name="EN-US_TOPIC_0000001188270540__li883632415101"></a><a name="li883632415101"></a>Masking character, which can be any one character, for example, an asterisk (*) or a number sign (#).</p>
|
|
</li><li id="EN-US_TOPIC_0000001188270540__li194691927161013">mask_from<p id="EN-US_TOPIC_0000001188270540__p17328184810185"><a name="EN-US_TOPIC_0000001188270540__li194691927161013"></a><a name="li194691927161013"></a>First character in the string that will be masked. The value must be greater than <strong id="EN-US_TOPIC_0000001188270540__b103254227416">0</strong>.</p>
|
|
</li><li id="EN-US_TOPIC_0000001188270540__li5489230161010">mask_to<p id="EN-US_TOPIC_0000001188270540__p14303192112194"><a name="EN-US_TOPIC_0000001188270540__li5489230161010"></a><a name="li5489230161010"></a>Last character in the string that will be masked. The default value can be used, which indicates that the character from the <strong id="EN-US_TOPIC_0000001188270540__b6727458124419">mask_from</strong> position to the last character of the string will be masked.</p>
|
|
</li></ul>
|
|
<p id="EN-US_TOPIC_0000001188270540__p51890911188">Return type: same as <strong id="EN-US_TOPIC_0000001188270540__b51478275466">column_name</strong></p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001188270540__section5311917177"><h4 class="sectiontitle">mask_partial(column_name, mask_field1, mask_value1, mask_field2, mask_value2, mask_field3, mask_value3)</h4><p id="EN-US_TOPIC_0000001188270540__p12698162021713">Description: Masks a date or time based on three specified fields. If <strong id="EN-US_TOPIC_0000001188270540__b144414442141">mask_value</strong> is <strong id="EN-US_TOPIC_0000001188270540__b10702149101419">-1</strong>, the corresponding <strong id="EN-US_TOPIC_0000001188270540__b5652041819">mask_field</strong> is not masked. <strong id="EN-US_TOPIC_0000001188270540__b12542164771811">mask_field</strong> can be <strong id="EN-US_TOPIC_0000001188270540__b1622415591812">month</strong>, <strong id="EN-US_TOPIC_0000001188270540__b1532310114195">day</strong>, <strong id="EN-US_TOPIC_0000001188270540__b8769361191">year</strong>, <strong id="EN-US_TOPIC_0000001188270540__b12785111221911">hour</strong>, <strong id="EN-US_TOPIC_0000001188270540__b16450418161910">minute</strong>, or <strong id="EN-US_TOPIC_0000001188270540__b17227143081915">second</strong>. The value range of each field must be within that of the actual time unit.</p>
|
|
<p id="EN-US_TOPIC_0000001188270540__p156981320131720">Return type: same as <strong id="EN-US_TOPIC_0000001188270540__b35963897">column_name</strong></p>
|
|
</div>
|
|
<div class="note" id="EN-US_TOPIC_0000001188270540__note16337191611512"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001188270540__p171717331517">Masking functions are recommended if you want to create masking policies.</p>
|
|
<p id="EN-US_TOPIC_0000001188270540__p59071543146">For details about how to use data masking functions, see the examples in in "Database Security Management > Sensitive Data Management > Data Masking" in the <em id="EN-US_TOPIC_0000001188270540__i5803878529237">Developer Guide</em>.</p>
|
|
</div></div>
|
|
<div class="section" id="EN-US_TOPIC_0000001188270540__section1435103610126"><h4 class="sectiontitle">User-Defined Masking Functions</h4><p id="EN-US_TOPIC_0000001188270540__p9419172671016">You can use the PL/pgSQL language to customize masking functions.</p>
|
|
<div class="p" id="EN-US_TOPIC_0000001188270540__p1774511212033">User-defined masking functions must meet the following requirements:<ul id="EN-US_TOPIC_0000001188270540__ul1736765821515"><li id="EN-US_TOPIC_0000001188270540__li10367145831516">The return type must be the same as the data type of the redacted column.</li><li id="EN-US_TOPIC_0000001188270540__li14368125821516">The functions can be pushed down.</li><li id="EN-US_TOPIC_0000001188270540__li436895841519">In addition to the masking format, only one column can be specified in the argument list for data masking.</li><li id="EN-US_TOPIC_0000001188270540__li1336875815155">The functions only implement the formatting for specific data types and do not involve complex association operations with other table objects.</li></ul>
|
|
</div>
|
|
<p id="EN-US_TOPIC_0000001188270540__p20663231830">If either of the first two requirements is not met, an error will be reported when you create a masking policy. If either of the last two requirements is not met, unexpected problems may occur in query execution results.</p>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_06_0027.html">Functions and Operators</a></div>
|
|
</div>
|
|
</div>
|
|
|