Exam 1z0-071 All QuestionsBrowse all questions from this exam
Question 55

BOOK_SEQ is an existing sequence in your schema.

Which two CREATE TABLE commands are valid? (Choose two.)

A.

B.

C. C.

D.

E.

    Correct Answer:

    The valid CREATE TABLE commands are A and D. Let's analyze why these are correct: A. This statement is valid because it uses BOOK_SEQ.NEXTVAL to automatically generate a unique primary key value for each row in the table. The SYSDATE function for the start_date and end_date columns is also valid. B. This statement is invalid because it tries to use a logical expression (end_date >= start_date) in the DEFAULT clause, which is not allowed. C. This statement is invalid because it uses BOOK_SEQ.CURRVAL for the bk_id column. CURRVAL might not have a value when the sequence is first used, causing issues. Additionally, it has the NOT NULL constraint before the DEFAULT clause, which is incorrect syntax. D. This statement is valid because it correctly defines the bk_id as NOT NULL and PRIMARY KEY, which is indeed redundant since PRIMARY KEY implies NOT NULL, but it is still syntactically valid. The use of the SYSDATE function for start_date and end_date is also valid. E. This statement is invalid because it references another column (start_date) in the DEFAULT clause, which is not allowed.

Discussion
ArslanAltaf

for Book.seq currval- is there a logical error despite the statement does execute?

hmatinnn

How not null and primary key can be set on the same column as primary key = not null + unique key ? I checked it is possible but technically it should not work in that way

boddoju

Can any one explain A,D are the correct answers

anzac

A is correct because it have valid order of statements: DEFAULT ____ NOT NULL From this reason C is not valid because it have NOT NULL DEFAULT _____ which is wrong order. B and E are not valid because the are mentioning other columns in default statement.

holdfaststrongly

CURRVAL might have a null value so option C may not work.

karols32

so what not an option E?

karols32

nvm, column cannot be a default value in next column.

Orxan_H

in which situations currval may be Null?