I want to encrypt a column with sensitive information in Snowflake. The usual syntax to encrypt a column is ENCRYPT( <value_to_encrypt> , <passphrase>)
The tricky part is that the column name has spaces. If I enclose it in single quotes, Snowflake is encrypting the column name itself and if I enclose in double quotes, it is resulting in a syntax error
CodePudding user response:
It is possible, the value to be encrypted has to be provided exactly as defined during CREATE TABLE:
CREATE TABLE tab(id INT, "col with space" TEXT);
INSERT INTO tab(id, "col with space") VALUES (1, 'abc');
SELECT id, "col with space", ENCRYPT("col with space", 'my_pass_phrase')
FROM tab;
Output: