Skip to content
Advertisement

How do I set every row in a column equal to a specific string?

I have some columns I want to set to the string ‘redacted’ because they contain personal information.

Currently I am creating views in snowflake from the original tables via a select statement how can I add a specified string to the particular columns?

original

name    number
john   | 1
mary   | 2
nikhil | 3

desired state

name      number
Redacted | 1
Redacted | 2
Redacted | 3

current code to materialize views

CREATE OR REPLACE SECURE VIEW "DB"."Schema"."Table"
AS
SELECT
    Column1,
    Column2,
    Column3,
FROM "DB"."Schema"."Table"

Advertisement

Answer

I think you want this, just define name as a constant in the view:

CREATE OR REPLACE SECURE VIEW "DB"."Schema"."Table"
AS
SELECT
    'redacted' name,
    number
FROM "DB"."Schema"."Table"

(but the code you provided for your view doesn’t match the desired results)

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement