Evaluate the following SQL commands:
The command to create a table fails. Identify the two reasons for the SQL statement failure?
A.
You cannot use SYSDATE in the condition of a check constraint.
B.
You cannot use the BETWEEN clause in the condition of a check constraint.
C.
You cannot use the NEXTVAL sequence value as a default value for a column.
D.
You cannot use ORD_NO and ITEM_NO columns as a composite primary key because
ORD_NO is also the foreign key.
Explanation:
CHECK Constraint
The CHECK constraint defines a condition that each row must satisfy. The condition can use
the same constructs as the query conditions, with the following exceptions:
References to the CURRVAL, NEXTVAL, LEVEL, and ROWNUM pseudocolumns
Calls to SYSDATE, UID, USER, and USERENV functions
Queries that refer to other values in other rows
A single column can have multiple CHECK constraints that refer to the column in its
definition.
There is no limit to the number of CHECK constraints that you can define on a column.
CHECK constraints can be defined at the column level or table level.
CREATE TABLE employees
(…
Salary NUMBER(8, 2) CONSTRAINT emp_salary_min
CHECK (salary > 0),
SQL> CREATE SEQUENCE ocaex1;
Sequence created.
SQL> CREATE TABLE ocaexample1 (
2 ID NUMBER DEFAULT ocaex1.NEXTVAL,
3* NAME VARCHAR2 (20))
SQL> /
Table created.
The pseudocolumns NEXTVAL and CURRVAL can be used as DEFAULT [ON NULL] values for
numeric columns. The sequence_name.NEXTVAL or sequence_name.CURRVAL pseudocolumns
are used to retrieve the value from sequence. The sequence must exist before it can be used
in the table definition.
Answer C is not correct.
Correct answer would be:
You can use the NEXTVAL sequence value as a default value for a column.
in version 12c there is one raison that’s A. others is corrects.
Answer is A
Hi there, this weekend is pleasant designed for me, for the reason that this moment i am reading this fantastic educational paragraph here at my home.|