Uninstalling the clean rooms environment¶

To completely uninstall the clean room environment from your account, you must use the ACCOUNTADMIN role in the Snowflake account where the clean room application is installed. This will delete the clean rooms environment for all users in your account, both as clean room providers and clean room consumers.

Important

This procedure completely uninstalls the entire environment for your account, not just individual clean rooms.

To uninstall the clean rooms environment for your account:

  1. Delete all the clean rooms that you created as a provider.

  2. Uninstall all the clean rooms that you installed (joined) as a consumer.

  3. Run the following uninstall commands.

    Each SELECT CONCAT statement generates one or more SQL commands that you should run in a Snowflake worksheet in the account where you want to remove the clean rooms environment.

    -- Drop created and installed (joined) clean rooms, if you have not done so.
    
    USE ROLE ACCOUNTADMIN;
    
    -- 1: Drop listings --
    -- 1.1 Generate the SQL commands:
    SHOW listings;
    WITH listings AS (
        SELECT * FROM TABLE(result_scan(last_query_id()))
        WHERE "name" ilike 'SAMOOHA^_CLEANROOM^_%' ESCAPE '^'
    ),
    alter_n_drop_listings AS (
        SELECT 'ALTER LISTING ' || "name" || ' UNPUBLISH;DROP LISTING ' || "name" || ';'
        FROM listings WHERE "state" = 'PUBLISHED'
    ),
    drop_listings AS (
        SELECT 'DROP LISTING ' || "name" || ';'
        FROM listings WHERE "state" = 'UNPUBLISHED'
    )
    SELECT * FROM alter_n_drop_listings
    UNION ALL
    SELECT * FROM drop_listings;
    )
    -- 1.2 Run the ALTER LISTING commands generated by the previous SELECT statement.
    
    -- 2: Drop shares --
    -- 2.1 Generate the SQL commands:
    SHOW SHARES;
    SELECT CONCAT('DROP SHARE ', "name", ';')
      FROM TABLE(RESULT_SCAN(last_query_id()))
      WHERE "kind" = 'OUTBOUND'
        AND "name" LIKE 'SAMOOHA_CLEANROOM_%';
    
    -- 2.2 Run the DROP SHARE commands generated by the previous SELECT statement.
    
    -- These shares have to be dropped manually:
    DROP SHARE SAMOOHA_INTERNAL_GOVERNANCE_SUMMARY_SHARE_NAV2;
    DROP SHARE SAMOOHA_INTERNAL_LOGS_SHARE_NAV2;
    DROP SHARE SAMOOHA_INTERNAL_PROVIDER_METADATA_NAV2;
    DROP SHARE SAMOOHA_INTERNAL_GOVERNANCE_SUMMARY_SHARE_NAV2_LAF;
    
    -- 3: Drop applications --
    -- 3.1 Generate the SQL commands:
    SHOW APPLICATIONS;
    SELECT CONCAT('DROP APPLICATION ', "name", ' CASCADE;')
      FROM TABLE(RESULT_SCAN(last_query_id()))
      WHERE "name" LIKE 'SAMOOHA_CLEANROOM_APP_%';
    
    -- 3.2 Run the DROP APPLICATION commands generated by the previous SELECT statement.
    
    -- 4: Drop application packages --
    -- 4.1 Generate the SQL commands:
    SHOW APPLICATION PACKAGES;
    SELECT CONCAT('DROP APPLICATION PACKAGE ', "name", ' CASCADE;')
      FROM TABLE(RESULT_SCAN(last_query_id())) WHERE "name" LIKE 'SAMOOHA_CLEANROOM_%';
    
    -- 4.2 Run the DROP APPLICATION PACKAGE commands generated by the previous SELECT statement.
    
    -- 5: Drop databases --
    -- 5.1 Generate the SQL commands:
    SHOW DATABASES;
    SELECT CONCAT('DROP DATABASE ', "name", ';')
      FROM TABLE(RESULT_SCAN(last_query_id()))
      WHERE "name" = 'SAMOOHA_SAMPLE_DATABASE'
        OR "name" LIKE 'SAMOOHA_CLEANROOM_%'
        OR "name" = 'SAMOOHA_BY_SNOWFLAKE_LOCAL_DB'
        OR "name" LIKE 'SAMOOHA_INTERNAL_GOVERNANCE_%'
        AND NOT startswith("name", 'SAMOOHA_CLEANROOM_CONSUMER_');
    
    -- 5.2 Run the DROP DATABASE commands generated by the previous SELECT statement.
    
    -- 6: Drop warehouses --
    -- 6.1 Generate the SQL commands:
    SHOW WAREHOUSES;
    SELECT 'DROP WAREHOUSE IF EXISTS ' || "name" || ';' AS drop_statements
    FROM TABLE(RESULT_SCAN(LAST_QUERY_ID()))
    WHERE "name" LIKE 'APP\_WH%'
      OR "name" LIKE 'DCR\_WH%'
      OR "name" LIKE 'PROVIDER\_RUN\_%'
      OR "name" LIKE 'SAMOOHA_TASK_WAREHOUSE'
    ORDER BY "name";
    
    -- 6.2 Run the DROP WAREHOUSES commands generated by the previous SELECT statement.
    
    -- 7: Finally drop the Snowflake native app
    DROP APPLICATION SAMOOHA_BY_SNOWFLAKE CASCADE;
    
    Copy
  4. If you want to delete your organization from Snowflake Data Clean rooms, contact Snowflake Support.