Given table 'StudAtt' with structure as Rno, Attdate, Attendance.
Identify the suitable command to add a primary key to the table after table creation.
Note: In the given case, we want to make both Rno and Attdate columns as primary key.
Given table 'StudAtt' with structure as Rno, Attdate, Attendance.
Identify the suitable command to add a primary key to the table after table creation.
Note: In the given case, we want to make both Rno and Attdate columns as primary key.
Solution
Option 1 is correct. A primary key is added to an existing table with ALTER TABLE ... ADD PRIMARY KEY, and the columns go inside the brackets. Listing both Rno and Attdate makes a composite primary key. The pair of values must be unique, which suits attendance records: one student (Rno) can have many dates, and one date can have many students.
Option 2: CREATE TABLE makes a new table and cannot modify an existing one. It also names only Rno.
Option 3: no column is named, so the command is incomplete.
Option 4: a table can have only one primary key. Two separate PRIMARY KEY clauses are invalid, so a multi-column key must be written as one composite key.
Related questions:
2026: 21 May Shift 1
2025: 27 May Shift 2
2025: 14 May Shift 1