An Interest In:
Web News this Week
- April 24, 2024
- April 23, 2024
- April 22, 2024
- April 21, 2024
- April 20, 2024
- April 19, 2024
- April 18, 2024
December 12, 2022 07:55 am GMT
Original Link: https://dev.to/asifroyal/in-postgres-perform-a-partial-match-on-an-encrypted-column-value-5bal
In Postgres, perform a partial match on an encrypted column value
In Postgres, you can execute a partial match on an encrypted column value. This will, however, necessitate the usage of a trigram index and the pg_trgm extension. Here's an illustration:
-- Enable the pg_trgm extensionCREATE EXTENSION pg_trgm;-- Create a table with an encrypted columnCREATE TABLE encrypted_data ( id SERIAL PRIMARY KEY, encrypted_column TEXT ENCRYPTED USING 'aes');-- Insert some encrypted dataINSERT INTO encrypted_data (encrypted_column)VALUES ('encrypted value 1'), ('encrypted value 2');-- Create a trigram index on the encrypted columnCREATE INDEX encrypted_data_encrypted_column_trigram_idxON encrypted_data USING gin (encrypted_column gin_trgm_ops);-- Perform a partial match on the encrypted columnSELECT *FROM encrypted_dataWHERE encrypted_column % 'encrypt';
This will return all rows that have the substring 'encrypt' in the encrypted encrypted_column value.
Original Link: https://dev.to/asifroyal/in-postgres-perform-a-partial-match-on-an-encrypted-column-value-5bal
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To