Bird
0
0

Why does PostgreSQL require explicit column definitions in RETURNS TABLE functions instead of inferring them automatically?

hard📝 Conceptual Q10 of 15
PostgreSQL - Advanced PL/pgSQL
Why does PostgreSQL require explicit column definitions in RETURNS TABLE functions instead of inferring them automatically?
ABecause RETURNS TABLE functions cannot return NULL values
BBecause PostgreSQL cannot execute queries inside functions
CTo prevent functions from returning multiple rows
DTo ensure the function's output structure is clear and consistent
Step-by-Step Solution
Solution:
  1. Step 1: Understand the purpose of explicit column definitions

    Explicit column definitions make the output structure clear, helping clients and tools know what to expect.
  2. Step 2: Evaluate incorrect options

    PostgreSQL can execute queries inside functions, functions can return multiple rows, and NULL values are allowed.
  3. Final Answer:

    To ensure the function's output structure is clear and consistent -> Option D
  4. Quick Check:

    Explicit columns clarify output structure = A [OK]
Quick Trick: Explicit columns define clear output structure for RETURNS TABLE [OK]
Common Mistakes:
  • Thinking PostgreSQL cannot run queries in functions
  • Believing RETURNS TABLE forbids multiple rows
  • Assuming NULL values are disallowed

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes