Bird
0
0

Which of the following is the correct syntax to define a composite type named person with fields name (text) and age (integer)?

easy📝 Syntax Q12 of 15
PostgreSQL - Advanced Features
Which of the following is the correct syntax to define a composite type named person with fields name (text) and age (integer)?
ACREATE TYPE person AS (name text, age integer);
BCREATE TABLE person (name text, age integer);
CCREATE TYPE person (name text, age integer);
DCREATE COMPOSITE person AS (name text, age integer);
Step-by-Step Solution
Solution:
  1. Step 1: Recall the syntax for creating composite types

    The correct syntax uses CREATE TYPE with AS and parentheses listing fields and types.
  2. Step 2: Check each option

    CREATE TYPE person AS (name text, age integer); matches the correct syntax. CREATE TABLE person (name text, age integer); creates a table, not a type. CREATE TYPE person (name text, age integer); misses AS keyword. CREATE COMPOSITE person AS (name text, age integer); uses invalid keyword COMPOSITE.
  3. Final Answer:

    CREATE TYPE person AS (name text, age integer); -> Option A
  4. Quick Check:

    CREATE TYPE ... AS (...) is correct [OK]
Quick Trick: Use CREATE TYPE name AS (fields) for composite types [OK]
Common Mistakes:
  • Using CREATE TABLE instead of CREATE TYPE
  • Omitting AS keyword
  • Using non-existent COMPOSITE keyword

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes