【发布时间】:2018-12-24 09:45:22
【问题描述】:
即使在 SQL Server 2019 版本中,我也无法对加密列进行模式匹配。
SQL Server 2019
加密前
select *
from messageencryption;
输出:
id msgcode msg
-------------------------------------------
1 AA56B this is a text message
2 AA56C this is a text123 message
3 AA56D EXTENDED BOOTCAMP
4 AA56E extended bootcamp
5 AA56J advance happy new year
6 AA56K oneteam
7 AA56L cricket team consists of 11 players
8 AA56M indian cricket team
select *
from messageencryption
where msg like '%team%';
输出:
id msgcode msg
----------------------------
6 AA56K onesmallteam
7 AA56L cricket team consists of 11 players
8 AA56M indian cricket team
之后加密:
select *
from messageencryption
where msg like '%team%';
输出
消息 402,第 16 级,状态 2,第 23 行
使用 (encryption_type = 'RANDOMIZED', encryption_algorithm_name = 'AEAD_AES_256_CBC_HMAC_SHA_256', column_encryption_key_name = 'cek', column_encryption_key_database_name = 'encrypt') collation_name = 'Latin1_General_BIN2' 和 varchar 在 like 运算符中不兼容。
预期输出:
id msgcode msg
----------------------------
6 AA56K onesmallteam
7 AA56L cricket team consists of 11 players
8 AA56M indian cricket team
【问题讨论】:
-
相关:stackoverflow.com/q/53275478/1220550(无法标记为重复,因为很遗憾答案未被接受)
-
根据 AlwaysEncrypted 上的官方文档docs.microsoft.com/en-us/sql/relational-databases/security/…,除了相等之外,您不能进行其他操作:
Queries can perform equality comparison on columns encrypted using deterministic encryption, but no other operations (for example, greater/less than, pattern matching using the LIKE operator, or arithmetical operations).。
标签: sql-server encryption always-encrypted