Bird
0
0

Which of the following is the correct syntax to force PostgreSQL to store a CTE result instead of inlining it?

easy📝 Syntax Q12 of 15
PostgreSQL - Common Table Expressions
Which of the following is the correct syntax to force PostgreSQL to store a CTE result instead of inlining it?
AWITH cte_name AS (SELECT * FROM table_name) MATERIALIZED
BWITH cte_name AS NOT MATERIALIZED (SELECT * FROM table_name)
CWITH cte_name AS MATERIALIZED (SELECT * FROM table_name)
DWITH cte_name AS MATERIALIZED SELECT * FROM table_name
Step-by-Step Solution
Solution:
  1. Step 1: Recall correct CTE syntax with materialization

    PostgreSQL syntax to force materialization is WITH cte_name AS MATERIALIZED (query).
  2. Step 2: Check options for syntax correctness

    WITH cte_name AS MATERIALIZED (SELECT * FROM table_name) matches the correct syntax; others have misplaced keywords or missing parentheses.
  3. Final Answer:

    WITH cte_name AS MATERIALIZED (SELECT * FROM table_name) -> Option C
  4. Quick Check:

    Materialized keyword goes right after AS [OK]
Quick Trick: Use AS MATERIALIZED right before the query in parentheses [OK]
Common Mistakes:
  • Placing MATERIALIZED outside parentheses
  • Using NOT MATERIALIZED to force storage
  • Omitting parentheses around the query

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes