1Z0-060 · Question #157
You issue the following command to alter the country column in the departments table: Which statement is true?
The correct answer is B. It executes successfully and all the rows that have a null value for the country column will be updated. In Oracle Database, altering an existing column to add a DEFAULT value executes successfully and updates all existing rows that currently hold NULL in that column with the new default.
Question
You issue the following command to alter the country column in the departments table:
Which statement is true?
Options
- AIt produces an error because column definitions cannot be altered to add default values.
- BIt executes successfully and all the rows that have a null value for the country column will be updated
- CIt executes successfully. The modification to add the default value takes effect only from subsequent
- DIt produces an error because the data type for the column is not specified.
How the community answered
(40 responses)- A5% (2)
- B90% (36)
- C3% (1)
- D3% (1)
Why each option
In Oracle Database, altering an existing column to add a DEFAULT value executes successfully and updates all existing rows that currently hold NULL in that column with the new default.
Oracle's ALTER TABLE MODIFY syntax fully supports adding or changing a DEFAULT clause on a column; no error is raised because modifying default values is a legal DDL operation.
Oracle's ALTER TABLE MODIFY command executes without error when adding a DEFAULT clause, and existing rows that contain NULL for the modified column are updated to the new default value at the time the statement runs, in addition to the default being applied for future inserts where the column value is omitted.
The new default does not apply only to rows inserted after the ALTER statement; Oracle also applies the default retroactively to existing rows that currently have NULL in the column.
When modifying an existing column, the data type does not need to be re-specified in the MODIFY clause; Oracle retains the column's existing data type if it is omitted.
Concept tested: ALTER TABLE MODIFY column DEFAULT value effect on existing rows
Source: https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/ALTER-TABLE.html
Topics
Community Discussion
No community discussion yet for this question.