Question:

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: Sep 18, 2025
  • 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);
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is A

Solution and Explanation

Step 1: Recall composite key.
A composite primary key consists of two or more attributes together uniquely identifying a row.
Step 2: Apply to given table.
Here, both Rno (Roll number) and Attdate (Attendance Date) together uniquely identify a record. So, we need a composite primary key.
Step 3: Evaluate options.
- Option 1: Correct syntax to add a composite primary key.
- Option 2: Incorrect, CREATE TABLE cannot be used after creation, also only Rno included.
- Option 3: Incorrect, syntax incomplete.
- Option 4: Incorrect, a table can have only one primary key, not multiple separate ones.
Final Answer: \[ \boxed{\text{ALTER TABLE StudAtt ADD PRIMARY KEY(Rno, Attdate);}} \]
Was this answer helpful?
0
0

Questions Asked in CUET exam

View More Questions