ITPEC FE Morning April 2023 Question 29

Source exam: ITPEC FE Morning April 2023Topic: Databases

ITPEC FE Morning April 2023 — Question 29 of 80

SQL INSERT with column constraints — match column list to value types and limits.

Table employees has fields (in order): emp_id (integer, PK), emp_name (up to 10 chars), salary (decimal, up to 4 digits). No NOT NULL constraints.

Why (a) is correct:
- Columns listed: emp_id, emp_name

- Values: 4, 'Hulk' — types match, 'Hulk' = 4 chars ≤ 10

- salary is omitted → defaults to NULL (allowed since no NOT NULL constraint)

Why not others:
- (b) — columns are emp_id, salary, emp_name, values are 3, 'Taylor', 1700'Taylor' (string) goes into salary (decimal) — type mismatch

- (c)'Bartholomew' = 11 characters > emp_name limit of 10 — exceeds column size

- (d) — no column list, so values map by table order: salary = 15000 = 5 digits > 4-digit limit — exceeds column size

Key rule: When column names are specified in INSERT, values are matched positionally to the listed columns, not to the table's original column order. Always check type compatibility and size constraints for each value.

AI-generated — may contain errors

The original exam layout is preserved in the image so diagrams, formulas, tables, and code remain accurate.

This question comes from an official ITPEC past paper. ITPEC Practice is an independent study tool and is not affiliated with ITPEC. See the official FE past-paper collection or Report an issue.