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?
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?
The statement INSERT INTO t1 (c2, c3) VALUES (100, 100.00), (101, 101) will execute successfully. The table T1 has four columns: c1 (INTEGER), c2 (INTEGER NOT NULL), c3 (DECIMAL(11,2)) and c4 (TIMESTAMP WITH DEFAULT CURRENT TIMESTAMP). Option D correctly specifies values for c2 and c3. Despite the default value for c4, it need not be explicitly mentioned as it is automatically set. The missing c1 will be inserted as NULL, which is allowed. Option A is incorrect as it does not provide values for all columns. Option B and C fail because they do not respect the NOT NULL constraint for c2 and because they don't match all necessary columns.
The good answer is "D- INSERT INTO t1 (c2, c3) VALUES (100, 100.00), (101, 101) " C2 column has the constraint not null. The answer ""INSERT INTO t1(c1,c2) VALUES(100)" is not good because you have to insert two values. You will get the error SQL0117N The number of values assigned is not the same as the number of specified or implied columns or variables. SQLSTATE=42802
D is the correct answer. Option B is not correct. It will fail because the number of values do not match the number of columns called out in the statement.
D is the good one
D is the best option
D is correct [db2inst2@vbox1 ~]$ db2 "INSERT INTO t1 (c2, c3) VALUES (100, 100.00), (101, 101)" DB20000I The SQL command completed successfully. [db2inst2@vbox1 ~]$