Skip to main contentSkip to solution

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

✅ Correct Option: 1

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.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question