1Z0-052 · Question #10
Examine the command that is used to create a table: SQL> CREATE TABLE orders ( oid NUMBER(6) PRIMARY KEY, odate DATE, ccode NUMBER (6), oamt NUMBER(10,2) ) TABLESPACE users; Which two statements are…
The correct answer is B. A NOT NULL constraint is created on the OID column. D. The ORDERS table and a unique index are created in the USERS tablespace. Defining PRIMARY KEY on a column implicitly creates a NOT NULL constraint and a unique index, both residing in the specified tablespace.
Question
Examine the command that is used to create a table:
SQL> CREATE TABLE orders ( oid NUMBER(6) PRIMARY KEY, odate DATE, ccode NUMBER (6), oamt NUMBER(10,2) ) TABLESPACE users; Which two statements are true about the effect of the above command? (Choose two.)
Options
- AA CHECK constraint is created on the OID column.
- BA NOT NULL constraint is created on the OID column.
- CThe ORDERS table is the only object created in the USERS tablespace.
- DThe ORDERS table and a unique index are created in the USERS tablespace.
- EThe ORDERS table is created in the USERS tablespace and a unique index is created on the OID
How the community answered
(49 responses)- A12% (6)
- B80% (39)
- C2% (1)
- E6% (3)
Why each option
Defining PRIMARY KEY on a column implicitly creates a NOT NULL constraint and a unique index, both residing in the specified tablespace.
A PRIMARY KEY creates UNIQUE and NOT NULL constraints, not a CHECK constraint - CHECK constraints require explicit definition with a condition expression.
A PRIMARY KEY constraint enforces both uniqueness and non-nullability, so Oracle automatically creates an implicit NOT NULL constraint on the OID column.
Two objects are created: the ORDERS table and a unique index for PRIMARY KEY enforcement, so the table is not the only object in the USERS tablespace.
Oracle creates a unique index to enforce the PRIMARY KEY; because no separate tablespace is specified for the index, it is created in the same USERS tablespace as the table.
Choice E does not specify the tablespace for the unique index, making it ambiguous and incomplete - D correctly states that both the table and the unique index are placed in the USERS tablespace.
Concept tested: PRIMARY KEY constraint implicit behavior and index creation
Source: https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/CREATE-TABLE.html
Topics
Community Discussion
No community discussion yet for this question.