Bird
0
0

Which of the following is the correct syntax to create a materialized view named sales_summary from a table sales?

easy📝 Syntax Q12 of 15
PostgreSQL - Views and Materialized Views
Which of the following is the correct syntax to create a materialized view named sales_summary from a table sales?
ACREATE MATERIALIZED VIEW sales_summary AS SELECT * FROM sales;
BCREATE VIEW MATERIALIZED sales_summary AS SELECT * FROM sales;
CCREATE MATERIALIZED VIEW sales_summary SELECT * FROM sales;
DCREATE MATERIALIZED VIEW sales_summary FROM sales;
Step-by-Step Solution
Solution:
  1. Step 1: Recall the correct syntax for creating materialized views

    The correct syntax is: CREATE MATERIALIZED VIEW view_name AS SELECT ...
  2. Step 2: Check each option against this syntax

    CREATE MATERIALIZED VIEW sales_summary AS SELECT * FROM sales; matches exactly. CREATE VIEW MATERIALIZED sales_summary AS SELECT * FROM sales; swaps keywords incorrectly. CREATE MATERIALIZED VIEW sales_summary SELECT * FROM sales; misses the AS keyword. CREATE MATERIALIZED VIEW sales_summary FROM sales; uses FROM instead of AS and SELECT.
  3. Final Answer:

    CREATE MATERIALIZED VIEW sales_summary AS SELECT * FROM sales; -> Option A
  4. Quick Check:

    Syntax = CREATE MATERIALIZED VIEW ... AS SELECT ... [OK]
Quick Trick: Use 'AS SELECT' after materialized view name [OK]
Common Mistakes:
  • Omitting the AS keyword
  • Swapping VIEW and MATERIALIZED keywords
  • Using FROM instead of AS SELECT

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes