Code: --------- use role SYSADMIN; drop database if exists ramu; create database ramu; use ramu; create or replace table ramu.PUBLIC.employee_info(employee_id number , employee_name varchar(200), empl_password varchar(200), dept varchar(10)); -- insert values into employee table insert into ramu.PUBLIC.employee_info values(1,'Soham','Soham123','HR'), (2,'Rajdeep','Raja456@','Marketing'), (3,'Ranjith','Jiohi12','HR'), (4,'Sudeshna','helloworld12','Support'), (5,'Surojit','bmps123','BI'), (6,'Sayan','jalo1i123','Management');
select * from ramu.PUBLIC.employee_info; USE ROLE ACCOUNTADMIN; create or replace masking policy sensitive_info_masking_string as (val STRING) returns STRING -> case when current_role() in ('ACCOUNTADMIN') then val else sha2(val) end;
ALTER TABLE IF EXISTS ramu.PUBLIC.employee_info MODIFY COLUMN empl_password SET MASKING POLICY sensitive_info_masking_string; select * from ramu.PUBLIC.employee_info; USE ROLE SYSADMIN; select * from ramu.PUBLIC.employee_info; select * from ramu.PUBLIC.employee_info where employee_name='Soham' and EMPL_PASSWORD=sha2('Soham123');
Code:
---------
use role SYSADMIN;
drop database if exists ramu;
create database ramu;
use ramu;
create or replace table ramu.PUBLIC.employee_info(employee_id number , employee_name varchar(200),
empl_password varchar(200),
dept varchar(10));
-- insert values into employee table
insert into ramu.PUBLIC.employee_info values(1,'Soham','Soham123','HR'),
(2,'Rajdeep','Raja456@','Marketing'),
(3,'Ranjith','Jiohi12','HR'),
(4,'Sudeshna','helloworld12','Support'),
(5,'Surojit','bmps123','BI'),
(6,'Sayan','jalo1i123','Management');
select * from ramu.PUBLIC.employee_info;
USE ROLE ACCOUNTADMIN;
create or replace masking policy sensitive_info_masking_string as (val STRING) returns STRING ->
case
when current_role() in ('ACCOUNTADMIN') then val
else sha2(val)
end;
ALTER TABLE IF EXISTS ramu.PUBLIC.employee_info MODIFY COLUMN empl_password SET MASKING POLICY sensitive_info_masking_string;
select * from ramu.PUBLIC.employee_info;
USE ROLE SYSADMIN;
select * from ramu.PUBLIC.employee_info;
select * from ramu.PUBLIC.employee_info where employee_name='Soham' and EMPL_PASSWORD=sha2('Soham123');
Thanks a lot !
You are welcome @zanarkiel! Happy Learning :-)
Bro, can you please make a video on end to end project using snowflake and aws services