Oracle Database 11g: Program with PL/SQL — Question 22
Examine the following snippet of code from the DECLARE section of PL/SQL
DECLARE -
Cust_name VERCHAR2 (20) NOT NULL : = Tom Jones:
Same_name cust_name%TYPE:
Which statement is correct about the above snippets of code?
Answer options
- A. The SAME_NAME variable inherits only the data type from the CUST_NAME variable.
- B. The SAME_NAME variable inherits only the data type and default value from the CUST_NAME variable.
- C. The SAME_NAME variable inherits the data type, constraint, and default value from the CUST_NAME variable.
- D. The SAME_NAME variable inherits only the data type and constraint from the CUST_NAME variable resulting in an error
Correct answer: D
Explanation
The correct answer is D because the SAME_NAME variable inherits only the data type and constraint from CUST_NAME, but it does not inherit the default value, which results in an error when trying to use a NOT NULL constraint without a default. Options A and B are incorrect as they misrepresent the inheritance of properties, and option C incorrectly states that the default value is inherited.