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?
- A. NULL, since it wasn't explicitly provided
- B. 0, the declared default value, since the column was omitted from the INSERT's column list
- C. The insert fails because the column is NOT NULL and wasn't provided
- 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
- A transaction executes UPDATE Accounts SET balance = balance - 100 WHERE id = 1; followed immediately (same transaction) by SELECT balance…
- A B+ tree index supports efficient range queries because leaf nodes are linked in sorted order. For a query WHERE age BETWEEN 25 AND 35…
- A table is partitioned by RANGE on a date column (e.g. one partition per year). A query filters WHERE saledate BETWEEN '2023-01-01' AND…
- A relation R(A, B, C, D, E) has FDs AB → CDE and E → B. What are the candidate key(s) of R?
- Using the same R(A, B, C, D, E) with AB → CDE and E → B, how many superkeys does R have in total?
- R(A, B, C) has NO nontrivial functional dependencies at all (every attribute is independent of every other). What is R's only candidate…