Tables, Keys & Constraints · Question 1 · Easy

A table Student(roll, name) already holds data. Which statement adds a new column city to it without losing the existing rows?

  1. ALTER TABLE Student ADD COLUMN city VARCHAR(30);
  2. UPDATE Student ADD COLUMN city VARCHAR(30);
  3. INSERT INTO Student (city) VALUES (NULL);
  4. CREATE TABLE Student (roll INT, name VARCHAR(30), city VARCHAR(30));
Answer and explanation

Answer: A. ALTER TABLE Student ADD COLUMN city VARCHAR(30);

Explanation: ALTER TABLE changes the structure of an existing table and keeps its rows. UPDATE and INSERT change data, not structure, and CREATE TABLE fails because the table already exists.

Next: What happens when the last statement runs?

Practise tables, keys & constraints

Try a fresh set of tables, keys & constraints questions with an explanation after every answer, free and without signing up: Tables, Keys & Constraints practice. Or sit a full placement mock test.

More tables, keys & constraints questions

More sql practice

DML & Transactions · SELECT, WHERE & ORDER BY · SQL Joins · Aggregates & GROUP BY · Subqueries & CTEs · Window Functions · NULL Handling · SQL Functions & CASE

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge