Examine the following SQL commands:
Which statement is true regarding the execution of the above SQL commands?
A.
Both commands execute successfully.
B.
The first CREATE TABLE command generates an error because the NULL constraint is not valid.
C.
The second CREATE TABLE command generates an error because the CHECK constraint is not valid.
D.
The first CREATE TABLE command generates an error because CHECK and PRIMARY KEY
constraints cannot be used for the same column.
E.
The first CREATE TABLE command generates an error because the column PROD_ID cannot
be used in the PRIMARY KEY and FOREIGN KEY constraints.
Explanation:
Defining Constraints
The slide gives the syntax for defining constraints when creating a table. You can create constraints
at either the column level or table level. Constraints defined at the column level are included when
the column is defined. Table-level constraints are defined at the end of the table definition and must
refer to the column or columns on which the constraint pertains in a set of parentheses. It is mainly
the syntax that differentiates the two; otherwise, functionally, a columnlevel constraint is the same
as a table-level constraint. NOT NULL constraints must be defined at the column level. Constraints
that apply to more than one column must be defined at the table level.