SOL-C01 · Question #156
You have a Snowflake table named 'products' with columns 'product id', 'product_name', and 'price'. You need to create a view called 'expensive_products' that only shows products with a price greater
The correct answer is A. Option A. The question's answer options aren't visible (they only show "Option A/B/C/D/E" without the actual SQL), so I'll explain the correct approach and common distractors based on the Snowflake concepts being tested. --- What Option A must contain to be correct: Option A is correct bec
Question
You have a Snowflake table named 'products' with columns 'product id', 'product_name', and 'price'. You need to create a view called 'expensive_products' that only shows products with a price greater than $100. However, you also want to ensure that only users with the 'PRODUCT VIEWER' role can access this view. What SQL statements are required to achieve this?
Exhibit
Options
- AOption A
- BOption B
- COption C
- DOption D
- EOption E
How the community answered
(18 responses)- A83% (15)
- B11% (2)
- C6% (1)
Explanation
The question's answer options aren't visible (they only show "Option A/B/C/D/E" without the actual SQL), so I'll explain the correct approach and common distractors based on the Snowflake concepts being tested.
What Option A must contain to be correct:
Option A is correct because it combines both required steps in proper Snowflake syntax:
CREATE VIEW expensive_products AS
SELECT product_id, product_name, price
FROM products
WHERE price > 100;
GRANT SELECT ON VIEW expensive_products TO ROLE PRODUCT_VIEWER;
Why distractors fail:
- Options using
CREATE TABLEinstead ofCREATE VIEWare wrong - views are virtual, not stored data. - Options using
WHERE price >= 100are wrong - the condition requires strictly greater than $100. - Options granting to a user instead of a role miss Snowflake's RBAC (Role-Based Access Control) model, where privileges are granted to roles, not users directly.
- Options omitting the
GRANTstatement create the view but leave access open to all users with schema access, violating the access-control requirement.
Memory tip: Think "CVG" - Create, View, Grant. In Snowflake, creating the view handles the filter logic, and the GRANT SELECT ON VIEW ... TO ROLE handles the access control - you always need both steps, and privileges go to roles, not users.
Topics
Community Discussion
No community discussion yet for this question.
