Question:medium

Given table 'StudAtt' with structure as (Rno, Attdate, Attendance). Identify the suitable command to add a primary key to the table after creation.
Note: We want to make both Rno and Attdate columns as primary key.

Show Hint

Use composite primary key when no single column can uniquely identify a row, but a combination can.
Updated On: Mar 19, 2026
  • ALTER TABLE StudAtt ADD PRIMARY KEY(Rno, Attdate);
  • CREATE TABLE StudAtt ADD PRIMARY KEY(Rno);
  • ALTER TABLE StudAtt ADD PRIMARY KEY;
  • ALTER TABLE StudAtt ADD PRIMARY KEY(Rno) AND PRIMARY KEY(Attdate);
Show Solution

The Correct Option is A

Solution and Explanation

Step 1: Understand Composite Keys.
A composite primary key is formed by combining two or more attributes that, together, uniquely identify a row.
Step 2: Application to the Table.
In this scenario, both Rno (Roll number) and Attdate (Attendance Date) are required to uniquely identify a record. Therefore, a composite primary key is necessary.
Step 3: Option Analysis.
- Option 1: Demonstrates the correct syntax for adding a composite primary key.
- Option 2: Incorrect because CREATE TABLE cannot be used post-creation, and it only includes Rno.
- Option 3: Incorrect due to incomplete syntax.
- Option 4: Incorrect, as a table can only have a single primary key, not multiple distinct ones.
Final Answer: \[\boxed{\text{ALTER TABLE StudAtt ADD PRIMARY KEY(Rno, Attdate);}}\]
Was this answer helpful?
1