Bird
0
0

Identify the error in this composite type usage:

medium📝 Debug Q6 of 15
PostgreSQL - Advanced Features
Identify the error in this composite type usage:
CREATE TYPE employee AS (name text, age integer);
CREATE TABLE staff (id serial, info employee);
INSERT INTO staff (info) VALUES ('John', 30);
AIncorrect insertion syntax for composite type value
BComposite type not created before table
CMissing PRIMARY KEY in table
DComposite type fields must be declared as NOT NULL
Step-by-Step Solution
Solution:
  1. Step 1: Check insertion syntax for composite types

    Composite type values must be inserted as a single composite value, not separate fields.
  2. Step 2: Identify correct insertion method

    Use ROW('John', 30) or a composite literal, not separate values.
  3. Final Answer:

    Incorrect insertion syntax for composite type value -> Option A
  4. Quick Check:

    Insert composite as ROW(...) or composite literal [OK]
Quick Trick: Insert composite values using ROW(...) or composite literals [OK]
Common Mistakes:
  • Inserting composite fields as separate columns
  • Ignoring composite type creation order
  • Assuming NOT NULL required on composite fields

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes