<code className=”samp”><em>custom_classifier</em></code>!ADD_REGEX

See also:

Using custom classifiers to implement custom semantic categories

为自定义分类器添加类和正则表达式,同时可为列名指定正则表达式和注释。

语法

<custom_classifier>!ADD_REGEX(
  SEMANTIC_CATEGORY => '<custom_category>' ,
  PRIVACY_CATEGORY => { 'IDENTIFIER' | 'QUASI-IDENTIFIER' | 'SENSITIVE' } ,
  VALUE_REGEX => '<regular_expression>' ,
  [ COL_NAME_REGEX => <regular_expression> ] ,
  [ DESCRIPTION => <string> ] ,
  [ THRESHOLD => <number> ]
)

实参

必填:

SEMANTIC_CATEGORY => custom_category

Specifies the name of the custom category (that is, type of information).

PRIVACY_CATEGORY => { 'IDENTIFIER' | 'QUASI-IDENTIFIER' | 'SENSITIVE' }

Specifies the sensitivity of the data, and can be one of the following values: 'IDENTIFIER', 'QUASI_IDENTIFIER', or 'SENSITIVE'.

VALUE_REGEX => regular_expression

指定正则表达式以匹配列中的值。

You can test the syntax of the regular expression by calling the REGEXP_LIKE function.

可选:

COL_NAME_REGEX => regular_expression

指定与要分类的列名匹配的正则表达式。

DESCRIPTION => string

Specifies a comment describing the custom category or the custom classifier that implements it.

THRESHOLD => number

Specifies the threshold value for the scoring rule. For more information, see Threshold for custom categories.

The acceptable range is greater than 0.0 and less than or equal to 1.0.

Default: 0.8.

输出

Returns a status message indicating the association of the category with the custom classifier in this format: classifier_name:category_name.

访问控制要求

A role used to execute this operation must have the following privileges at a minimum:

Instance roleObjectNotes
custom_classifier!PRIVACY_USERThe custom classification instance.

调用此方法的账户角色必须在自定义分类器上被授予此实例角色。

默认情况下,用于创建实例的账户角色可以调用此方法。

Operating on an object in a schema requires at least one privilege on the parent database and at least one privilege on the parent schema.

For instructions on creating a custom role with a specified set of privileges, see Creating custom roles.

For general information about roles and privilege grants for performing SQL actions on securable objects, see Overview of Access Control.

使用说明

  • 多次调用此方法会得到与该实例相关的正则表达式数量的累加结果。

  • 在单独的 SQL 语句中调用每个方法(无需方法链接)。

  • 所有用于分类目的的正则表达式搜索都不区分大小写。

  • Test the regular expression before adding a regular expression to the custom classification instance. For example, use the [ NOT ] REGEXP function to make sure that only values that match the regex are returned in the result:

    SELECT <col_to_classify>
    FROM <table_with_col_to_classify>
    WHERE <col_to_classify> REGEXP('<regex>');

    For details, see String functions (regular expressions).

示例

Add categories and a regular expression to the medical_codes instance:

CALL internal_ids!ADD_REGEX(
  SEMANTIC_CATEGORY => 'EMPLOYEE_ID',
  PRIVACY_CATEGORY => 'IDENTIFIER',
  VALUE_REGEX => '^[0-9]{6}$',
  COL_NAME_REGEX => 'EMP.*ID.*',
  DESCRIPTION => 'Add a regex to identify employee IDs in a column',
  THRESHOLD => 0.8
);

Returns:

+---------------+
|   ADD_REGEX   |
+---------------+
| EMPLOYEE_ID   |
+---------------+

Create a custom classifier that uses the default threshold and doesn’t use a regular expression to match column names:

CALL medical_codes!ADD_REGEX(
  SEMANTIC_CATEGORY => 'ICD_10_CODES',
  PRIVACY_CATEGORY => 'IDENTIFIER',
  VALUE_REGEX => '[A-TV-Z][0-9][0-9AB]\.?[0-9A-TV-Z]{0,4}'
);