IBM DB2 11.1 Advanced DBA for Linux, UNIX, and Windows — Question 2
The DDL statement is used to create table T1:
CREATE TABLEt1 (
c1 INTEGER,
c2 INTEGER NOT NULL,
c1 DECIMAL(11,2),
c4 TIMESTAMP WITH DEFAULT CURRENT TIMESTAMP
)
Which of the following INSERT statements will execute successfully?
Answer options
- A. INSERT INTO t1 VALUES (100)
- B. INSERT INTO t1 (c1, c2) VALUES (100)
- C. INSERT INTO t1 (c1, c3) VALUES ("˜100', "˜100.00')
- D. INSERT INTO t1 (c2, c3) VALUES (100, 100.00), (101, 101)
Correct answer: B
Explanation
The correct answer is B because it specifies both c1 and c2, with c2 being a required field. Option A fails since it does not provide values for the NOT NULL column c2. Option C is incorrect because it attempts to insert into c3, which does not exist in the table definition. Option D also fails for the same reason as it references c3.