Skip to main content

Posts

Showing posts with the label Data Masking

PostgreSQL Data Masking Tricks

Hi, SQL Server announced Dynamic Data Masking feature not long ago and I'm Postgresql DBA! PostgreSQL does not have like that feature yet. So, what if we need data masking on our database's tables? If you need make strict your database tables and hide your column but not that all follow bellow function! This function shows only the first and last two characters. If you looking for some solution for your table's column and if it is the character you can create bellow function in your database and enjoy it! CREATE OR REPLACE FUNCTION dba.pg_datamask_column(col character varying)   RETURNS character varying AS $BODY$ begin  if (select length(col))<=2 then return col; elsif (select length(col))=3 or  (select length(col))=4  then return  (select replace(col,right(col,2),'xx')); else return (select  replace(substring(col from 1 for length(col)-2), right(substring(col from 1 for length(col)-2),length(col)-4),'xxxx')||right(col,2)); end if;...