Examine the structure proposed for the TRANSACTIONS table:
name Null Type
TRANS_ID NOT NULL NUMBER(6)
CUST_NAME NOT NULL VARCHAR2(20)
CUST_STATUS NOT NULL CHAR
TRANS_DATE NOT NULL DATE
TRANS_VALIDITY VARCHAR2
CUST_CREDIT_LIMIT NUMBER
Which statements are true regarding the creation and storage of data in the above table structure? (Choose
all that apply.)
A.
The CUST_STATUS column would give an error.
B.
The TRANS_VALIDITY column would give an error.
C.
The CUST_STATUS column would store exactly one character.
D.
The CUST_CREDIT_LIMIT column would not be able to store decimal values.
E.
The TRANS_VALIDITY column would have a maximum size of one character.
F.
The TRANS_DATE column would be able to store day, month, century, year, hour, minutes, seconds, and fractions of seconds.
Can anybody explain why the option B is correct?
You need to specify a maximum string length for varchar2(varchar2(3999), fe.)
Please explain on option E, why isn’t it correct?
When you define a column of type Varchar2 you need to specify the length. The minimal is 1. That is why B is correct.
thanks Justyna
sorry I meant option F.
The TRANS_DATE column would be able to store day, month, century, year, hour, minutes, seconds, and fractions of seconds.
Why is option F incorrect? Per Oracle: DATE datatype stores the year (including the century), the month, the day, the hours, the minutes, and the seconds (after midnight).
TRANS_DATE is of type Date so cannot store fractions of seconds
C is not correct: The CUST_STATUS column would store exactly one character.
The length of CHAR was not specified. It is incorrect.
For CHAR datatype default length is 1 and you do not need to specify it.
Why is D incorrect?
If no scale is specified, the scale is zero(http://docs.oracle.com/cd/B28359_01/server.111/b28318/datatype.htm#CNCPT1832)
So the CUST_CREDIT_LIMIT column would not be able to store decimal values, which makes D true.
B and C are correct because
B reason:When you create a table with a VARCHAR2 column, you specify a maximum string length (in bytes or characters) between 1 and 4000 bytes for the VARCHAR2 column
C reason:When you create a table with a CHAR column, you must specify a string length (in bytes or characters) between 1 and 2000 bytes for the CHAR column width. The default is 1 byte.
Option A should be correct. You cannot specify NOT NULL before the data type for a column.
A is correct! The CUST_STATUS column will give error. Must state colName dataType Not Null (if required). The first attribute is colName, the second Must be dataType.
B is correct! The TRANS_VALIDITY VARCHAR2, will give error because MUST DEFINE length eg. VARCHAR2(10), or any integer inside parenthesis.
C is INCORRECT! The CUST_STATUS column would store exactly one character. Only if you switch NOT NULL and CHAR around.
This is wrong: CUST_STATUS NOT NULL CHAR
This is right: CUST_STATUS CHAR NOT NULL. And NO you do not need to define length. It will default to 1. NOT LIKE VARCHAR2…. it requires parenthesis with an integer inside.
D is wrong! Number can store decimals even without stating number(4, 2) for example.
E is wrong! TRANS_VALIDITY VARCHAR2 results in error as explained above. MUST define length.
F is wrong! TRANS_DATE NOT NULL DATE fails for TWO reasons. First NOT NULL must come after data type (DATE) and fractions of seconds are only available with timestamp datatypes.
VERY POORLY WRITTEN QUESTION!
THerefore,
TRANS_ID NOT NULL NUMBER(6) will give error
CUST_NAME NOT NULL VARCHAR2(20) will give error
CUST_STATUS NOT NULL CHAR will give error
TRANS_DATE NOT NULL DATE will give error
@donald : It’s description of table. try Desc emp; You ll see how table is described in oracle. I’ just how table structure is described.
B & C is correct Answer.
@donald : It’s description of table. try Desc emp; You ll see how table is described in oracle.
B & C is correct Answer.