Skip to content
Question 21 of 40

Q.Which MySQL command helps to add a primary key constraint to any table that has already been created ? (A) UPDATE (B) INSERT INTO (C) ALTER TABLE (D) ORDER BY

Sikkim CbseCBSE Class XII Board 2024MCQ· 1mImportance★★★★★
53% · 21/40 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

Primary key constraints on existing tables are added through schema modification commands. The answer is (C) ALTER TABLE.

When you create a table in MySQL, you define its structure: column names, data types, and constraints like primary keys. But what happens when you've already created a table and later realize you need to add a primary key? You need a command that modifies the table's structure itself, not its data.

This is where the distinction between Data Definition Language (DDL) and Data Manipulation Language (DML) becomes crucial. DDL commands change the schema—the blueprint of your database objects. DML commands work with the data inside those objects.

Let's examine each option:

  1. UPDATE is a DML command that modifies existing data in rows. You use it to change values in columns, like UPDATE students SET grade = 'A' WHERE id = 5. It cannot alter the table's structure or add constraints.

  2. INSERT INTO is another DML command that adds new rows of data to a table. It populates the table with records but has no capability to modify the table definition itself.

  3. ALTER TABLE is the DDL command specifically designed to modify an existing table's structure. You can add columns, drop columns, change data types, and crucially, add or remove constraints like primary keys, foreign keys, and unique constraints. …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.