Multiple choice technology databases

You need to modify the STUDENTS table to add a primary key on the STUDENT_ID column. The table is currently empty. Which statement accomplishes this task?

  1. ALTER TABLE students ADD PRIMARY KEY student_id;

  2. ALTER TABLE students ADD CONSTRAINT PRIMARY KEY (student _ id);

  3. ALTER TABLE students ADD CONSTRAINT stud_id_pk PRIMARY KEY (student _ id);

  4. ALTER TABLE students ADD CONSTRAINT stud _ id _pk PRIMARY KEY (student _ id);

  5. ALTER TABLE students MODIFY CONSTRAINT stud _ id _pk PRIMARY KEY (student _ id);

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

To add a primary key with ALTER TABLE, you must use ADD CONSTRAINT with a constraint name and PRIMARY KEY keyword. Option D follows the correct syntax, though note that the column name appears to have unusual spacing. Option A lacks parentheses and constraint name, B lacks the constraint name before PRIMARY KEY, C has potential naming issues, and E uses MODIFY which is not correct for adding constraints.