更新时间:2026-07-28 GMT+08:00
敏感数据发现
敏感数据发现功能提供函数gs_sensitive_data_discovery()和gs_sensitive_data_discovery_detail(),通过调用的不同函数,指定扫描对象和敏感数据分类器,得到对应扫描对象不同明细级别的敏感数据信息。
使用敏感数据发现函数扫描数据
- 创建扫描目标。
gaussdb=# CREATE SCHEMA test_schema1; gaussdb=# CREATE TABLE test_schema1.normal_table1 (email VARCHAR(50), phonenum text, creditcard bytea, name BPCHAR(50), encrypted_data NVARCHAR2(500)); gaussdb=# INSERT INTO test_schema1.normal_table1 VALUES ('Gauss_1@huawei.com', '13345678901', '4951-7843-2960-0886', '高斯', 'r1Pj4DKQopSmZfSr/mXwieGcrE+O2iX3G04w1Tda0zqX/pD/Az90tLuvy0ZnCmUg0/Kl/g89ZqxxAZzta8jQ6bvicRpdXrDCQTHAfsXYSEScB9Idqtwh7kdm1LHq89qs');
- 调用敏感数据发现函数扫描目标。
- 调用gs_sensitive_data_discovery()函数,扫描目标数据,返回统计的扫描结果。
gaussdb=# SELECT * FROM gs_sensitive_data_discovery('test_schema1.normal_table1', 'all'); target | percentage_of_sensitive_data | classifier_type_distribution ----------------------------+------------------------------+------------------------------------------------------------------------------------------ test_schema1.normal_table1 | 5/5 | Email: 1/5 CreditCard: 1/5 PhoneNumber: 1/5 ChineseName: 1/5 EncryptedContent: 1/5 (1 row) - 调用gs_sensitive_data_discovery_detail()函数,扫描目标数据,返回详细的扫描结果。
gaussdb=# SELECT * FROM gs_sensitive_data_discovery_detail('test_schema1', 'all'); schema | table | column | classifier | laws_and_regulations --------------+---------------+----------------+------------------+---------------------- test_schema1 | normal_table1 | email | Email | GDPR test_schema1 | normal_table1 | phonenum | PhoneNumber | GDPR test_schema1 | normal_table1 | creditcard | CreditCard | GDPR test_schema1 | normal_table1 | name | ChineseName | GDPR test_schema1 | normal_table1 | encrypted_data | EncryptedContent | GDPR (5 rows)
- 调用gs_sensitive_data_discovery()函数,扫描目标数据,返回统计的扫描结果。
- 清理数据。
gaussdb=# DROP TABLE test_schema1.normal_table1; gaussdb=# DROP SCHEMA test_schema1; (3 row)
父主题: 特性使用指导