To solve this problem, the user needs to know the SQL syntax for adding a primary key to a table using the ALTER TABLE statement.
A primary key is a column or set of columns that uniquely identifies each row in a table. It is a constraint that ensures that the values in the column(s) are unique and not null.
Now let's go through each option and explain why it is right or wrong:
A. ALTER TABLE students ADD PRIMARY KEY student_id;
This statement is incorrect because it is missing the keyword "CONSTRAINT". The correct syntax for adding a primary key constraint is "ADD CONSTRAINT".
B. ALTER TABLE students ADD CONSTRAINT PRIMARY KEY(student_id);
This statement is incorrect because it is missing the name of the constraint. All constraints should have a unique name for easy identification and management.
C. ALTER TABLE students ADD CONSTRAINT stud_id_pk PRIMARY KEY student_id;
This statement is incorrect because the syntax is wrong. The correct syntax for adding a primary key constraint is "ADD CONSTRAINT PRIMARY KEY ()".
D. ALTER TABLE students ADD CONSTRAINT stud_id_pk PRIMARY KEY (student_id);
This statement is correct. It adds a primary key constraint named "stud_id_pk" to the "students" table on the "student_id" column.
E. ALTER TABLE Students MODIFY CONSTRAINT stud_id_pk PRIMARY KEY (student_id);
This statement is incorrect because it uses the "MODIFY CONSTRAINT" syntax, which is not valid for adding constraints.
Therefore, the correct answer is:
The Answer is: D. ALTER TABLE students ADD CONSTRAINT stud_id_pk PRIMARY KEY (student_id);