PrepAway - Latest Free Exam Questions & Answers

Which of the following CREATE statements will successfully create this table?

Given the following requirements:
Create a table named TESTTAB, which has an identity column named ACTIVITYNO. Define the
identity column to generate the values for the column by default. Start the values at 10 and
increment by 10. Make the identity column unique.
Which of the following CREATE statements will successfully create this table?

PrepAway - Latest Free Exam Questions & Answers

A.
CREATE TABLE TESTTAB
(ACTIVITYNO SMALLINT NOT NULL
GENERATED ALWAYS AS IDENTITY
(START WITH 10
INCREMENT BY 10),
ACTKWD CHAR(6) NOT NULL,
ACTDESC VARCHAR(20) NOT NULL,
UNIQUE(ACTIVITYNO))

B.
CREATE TABLE TESTTAB
(ACTIVITYNO SMALLINT NOT NULL
GENERATED ALWAYS AS IDENTITY
(START WITH 1
INCREMENT BY 10),
ACTKWD CHAR(6) NOT NULL,
ACTDESC VARCHAR(20) NOT NULL,
UNIQUE(ACTNO))

C.
CREATE TABLE TESTTAB
(ACTIVITYNO SMALLINT NOT NULL
GENERATED BY DEFAULT AS IDENTITY (START WITH 10 INCREMENT BY 1),
ACTKWD CHAR(6) NOT NULL,
ACTDESC VARCHAR(20) NOT NULL,
UNIQUE(ACTIVITYNO))

D.
CREATE TABLE TESTTAB
(ACTIVITYNO SMALLINT NOT NULL
GENERATED BY DEFAULT AS IDENTITY
(START WITH 10
INCREMENT BY 10),
ACTKWD CHAR(6) NOT NULL,
ACTDESC VARCHAR(20) NOT NULL,
UNIQUE(ACTIVITYNO))

One Comment on “Which of the following CREATE statements will successfully create this table?

  1. ra says:

    GENERATED BY DEFAULT AS IDENTITY clause.

    This will cause DB2 to generate unique values for the identity column during insert operations if no value is specified for the identity column. However, if a value is specified for the identity column, DB2 will use it in the insert operation.




    0



    0

Leave a Reply