Which of the following is a valid SQL statement to add a primary key to an existing table? MCQ with Answer and Explanation

Which of the following is a valid SQL statement to add a primary key to an existing table?
A. ADD PRIMARY KEY ON table_name (column_name);
B. ALTER TABLE table_name ADD CONSTRAINT pk_name PRIMARY KEY (column_name);
C. ALTER TABLE table_name ADD PRIMARY KEY (column_name);
D. Both A and C
Answer: Option D
Solution (By JKExamLibrary)
Both syntaxes are valid: ADD PRIMARY KEY (column) and ADD CONSTRAINT ... PRIMARY KEY (column).

Discuss this Question (0)

No comments yet. Be the first to start the discussion!

Practice More Database Management System (DBMS) Questions

Question #1
The range of all permissible and valid values that an attribute can hold is formally defined as its what?
A. Domain
B. Relation
C. Tuple
D. Schema

Correct Answer: Option A


Explanation:
A Domain is the pool of legal, atomic values from which an attribute can take its value.

This question belongs to: Computer Database Management System (DBMS)
Question #2
Which type of join returns all rows from the left table and matching rows from the right table?
A. INNER JOIN
B. LEFT JOIN
C. RIGHT JOIN
D. FULL JOIN

Correct Answer: Option B


Explanation:
LEFT JOIN (or LEFT OUTER JOIN) returns all rows from the left table, with matching rows from the right table; NULLs appear when no match.

This question belongs to: Computer Database Management System (DBMS)
Question #3
Which of the following is a type of database backup?
A. Full backup
B. Incremental backup
C. Differential backup
D. All of the above

Correct Answer: Option D


Explanation:
Full, incremental, and differential backups are common backup strategies.

This question belongs to: Computer Database Management System (DBMS)