SQL 服务器 - 在插入之前屏蔽/更改值 uniqueidentifier
SQL server - Masking / changing value uniqueidentifier before inserting
所以主要目标是在插入之前屏蔽或随机更改 uniqueidentifier 的值。
例如:
我有一个table
Create table Student
(
Student_ID masked WITH (FUNCTION='default()') DEFAULT NEWID()
Student_Name varchar(100),
)
我正在插入新数据:
insert into DDM_Student_Sample values ('B9BC5E61-0F3C-498F-AF2C-1AC16446A846','Stuart Little Joe')
结果与插入时的输出相同,即 uniqueidentifier = 'B9BC5E61-0F3C-498F-AF2C-1AC16446A846'
我创建了一个登录用户:
CREATE USER MAIN_USER FOR LOGIN MAIN_USER;
EXEC sp_addrolemember 'db_owner', 'MAIN_USER';
通过 toturial (http://www.sqlservercentral.com/articles/Security/149689/) 它说你必须创建用户 without login。也许这就是为什么 Student_ID 不会随机变化的问题。
最后,也许还有另一种方法可以在将数据插入到 table 之前随机更改它的值。或者我应该从前端改变价值?并写下类似:
model.StudentId = Guid.NewGuid();
model.SaveToDatabase();
insert into DDM_Student_Sample values (NEWID(),'Stuart Little Joe')
动态Sql 服务器数据屏蔽旨在防止意外泄露敏感数据。 它不会更改实际存储的值。它只是在显示数据之前将掩码应用于值。我认为这就是为什么它被称为 dynamic
The result is the same output as it was inserted
我猜,您看到实际值是因为您拥有 UNMASK
权限或 CONTROL
权限(包括 UNMASK
)。
此外,没有 UNMASK
权限的用户可以 "guess" 使用简单 select
的实际值
select from Student where Student_ID = 'B9BC5E61-0F3C-498F-AF2C-1AC16446A846'
它将显示具有屏蔽值的行。
maybe there is another way before inserting data to table change it value randomly
这取决于您的需求。如果您需要恢复数据,您可以使用 column encrypting。如果你只需要丑化数据,你可以使用常规的数据库触发器,或者像你提到的那样从前端更改值。
所以主要目标是在插入之前屏蔽或随机更改 uniqueidentifier 的值。
例如: 我有一个table
Create table Student
(
Student_ID masked WITH (FUNCTION='default()') DEFAULT NEWID()
Student_Name varchar(100),
)
我正在插入新数据:
insert into DDM_Student_Sample values ('B9BC5E61-0F3C-498F-AF2C-1AC16446A846','Stuart Little Joe')
结果与插入时的输出相同,即 uniqueidentifier = 'B9BC5E61-0F3C-498F-AF2C-1AC16446A846'
我创建了一个登录用户:
CREATE USER MAIN_USER FOR LOGIN MAIN_USER;
EXEC sp_addrolemember 'db_owner', 'MAIN_USER';
通过 toturial (http://www.sqlservercentral.com/articles/Security/149689/) 它说你必须创建用户 without login。也许这就是为什么 Student_ID 不会随机变化的问题。
最后,也许还有另一种方法可以在将数据插入到 table 之前随机更改它的值。或者我应该从前端改变价值?并写下类似:
model.StudentId = Guid.NewGuid();
model.SaveToDatabase();
insert into DDM_Student_Sample values (NEWID(),'Stuart Little Joe')
动态Sql 服务器数据屏蔽旨在防止意外泄露敏感数据。 它不会更改实际存储的值。它只是在显示数据之前将掩码应用于值。我认为这就是为什么它被称为 dynamic
The result is the same output as it was inserted
我猜,您看到实际值是因为您拥有 UNMASK
权限或 CONTROL
权限(包括 UNMASK
)。
此外,没有 UNMASK
权限的用户可以 "guess" 使用简单 select
select from Student where Student_ID = 'B9BC5E61-0F3C-498F-AF2C-1AC16446A846'
它将显示具有屏蔽值的行。
maybe there is another way before inserting data to table change it value randomly
这取决于您的需求。如果您需要恢复数据,您可以使用 column encrypting。如果你只需要丑化数据,你可以使用常规的数据库触发器,或者像你提到的那样从前端更改值。