Bird
0
0

What will happen if you try to insert a value 'excited' into a column of ENUM type mood defined as ('happy', 'sad', 'neutral')?

medium📝 query result Q5 of 15
PostgreSQL - Advanced Features
What will happen if you try to insert a value 'excited' into a column of ENUM type mood defined as ('happy', 'sad', 'neutral')?
AThe insert will fail with an error about invalid input value
BThe value 'excited' will be automatically added to the ENUM type
CThe value will be stored as NULL silently
DThe insert will succeed but convert 'excited' to 'neutral'
Step-by-Step Solution
Solution:
  1. Step 1: Understand ENUM value restrictions

    Only predefined ENUM values are allowed; others cause errors.
  2. Step 2: Analyze insert behavior

    Inserting 'excited' not in ENUM causes an error, no automatic addition or conversion.
  3. Final Answer:

    The insert will fail with an error about invalid input value -> Option A
  4. Quick Check:

    Invalid ENUM insert = error, no silent conversion [OK]
Quick Trick: ENUM columns reject values not in defined list [OK]
Common Mistakes:
  • Thinking ENUM auto-adds new values
  • Expecting silent NULL insertion
  • Assuming automatic value conversion

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes