Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

#1. Modify the following SQL command so that the Rep_ID column is the PRIMARY KE

ID: 673102 • Letter: #

Question

#1. Modify the following SQL command so that the Rep_ID column is the PRIMARY KEY for the table and the default value of Y is assigned to the Comm column. ( The Comm column indicates whether the sales representative earns commission.)


CREATE TABLE store_reps
     ( rep_ID NUMBER( 5),
        last VARCHAR2( 15),
        first VARCHAR2( 10),
        comm CHAR( 1) );

I have this for my answer so far

CREATE TABLE store reps

(rep ID NUMBER(5),

last VARCHAR2(15,)

First VARCHAR2(10),

comm CHAR(1) NOT NULL,

CONSTRAINT store reps_rep ID_pk PRIMARY KEY (rep ID));

and than #3. Change the STORE_REPS table so that only a Y or N can be entered in the Comm column.

Explanation / Answer

CREATE TABLE store_reps

( rep_ID NUMBER(5),

last VARCHAR2(15),

first VARCHAR2 (10),

  comm CHAR(1) NOT NULL DEFAULT ‘Y’,

  PRIMARY KEY(rep_ID),

CONSTARINT comm_y_n CHECK (comm IN(‘Y’, ‘N’));