CS FundamentalsEasyTCS NQT · Infosys pattern

A column is declared `NOT NULL DEFAULT 0`. An application performs `INSERT INTO T (other_col) VALUES (5);` without mentioning this column at all. What value does this column get?

  1. A. NULL, since it wasn't explicitly provided
  2. B. 0, the declared default value, since the column was omitted from the INSERT's column list
  3. C. The insert fails because the column is NOT NULL and wasn't provided
  4. D. An error, because DEFAULT values only apply to columns explicitly set to DEFAULT in the VALUES list

Correct answer: B. 0, the declared default value, since the column was omitted from the INSERT's column list

When a column is omitted entirely from an INSERT's column list, the engine fills it with its declared DEFAULT value (0 here) rather than failing or using NULL; NOT NULL only blocks an explicit attempt to insert NULL, not the normal default-filling behaviour for omitted columns.

More DBMS and SQL questions

Exams that ask this topic