Bird
0
0

This SQL code has an error:

medium📝 Debug Q6 of 15
SQL - Table Relationships
This SQL code has an error:
CREATE TABLE Orders (id INT, customer_id INT, FOREIGN KEY customer_id REFERENCES Customers(id));

What is the error?
ANo error, code is correct
BMissing parentheses around foreign key column
CForeign key cannot reference another table
DWrong table name
Step-by-Step Solution
Solution:
  1. Step 1: Check foreign key syntax

    FOREIGN KEY columns must be enclosed in parentheses.
  2. Step 2: Identify error in code

    The code misses parentheses around customer_id in FOREIGN KEY clause.
  3. Final Answer:

    Missing parentheses around foreign key column -> Option B
  4. Quick Check:

    Foreign key columns need parentheses [OK]
Quick Trick: Always use parentheses around foreign key columns [OK]
Common Mistakes:
MISTAKES
  • Omitting parentheses
  • Misplacing FOREIGN KEY clause

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes