IBM DB2 11.1 Advanced DBA for Linux, UNIX, and Windows — Question 1
Below are the SQL statements a DBA is planning to execute on a database:
CREATE TABLE t1 (name VARCHAR (1));
INSERT INTO t1 VALUES ("˜A'), ("˜B'), ("˜C'), ("˜D');
ALTER TABLE t1 ALTER COLUMN name SET DATA TYPE INT;
What will be the outcome of the last statement?
Answer options
- A. The statement will fail due to variable length character error
- B. The statement will fail due to an incompatible data type error
- C. The statement will execute successfully and it deletes the character data
- D. The statement will execute successfully and it internally converts the character data into ASCII numbers
Correct answer: C
Explanation
The correct answer is C because the ALTER TABLE statement can change the data type of the column, and in this case, it effectively removes the character data without raising an error. Option A is incorrect as there is no variable length character error; option B is not applicable as the conversion does not trigger an incompatible data type error; option D is wrong because the data is deleted rather than converted.