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?
- ALTER TABLE Student ADD COLUMN city VARCHAR(30);
- UPDATE Student ADD COLUMN city VARCHAR(30);
- INSERT INTO Student (city) VALUES (NULL);
- 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
- What happens when the last statement runs?
- What does the final SELECT return?
- What happens when the INSERT runs?
- How many PRIMARY KEY constraints can one table have?
- Which statement can remove only those rows of a table that satisfy a…
- What happens when the INSERT with a price of -50 runs?
- In PostgreSQL, MySQL and SQLite, which follow the SQL standard on this point…
- Table Member: id | name 1 | Asha 2 | Bala The table Member below already has…
- Table Dept has rows (1, IT) and (2, HR). Table Emp has rows (10, Kiran, dept…
- Table Team has rows (1, Mumbai) and (2, Chennai). Table Player has rows…
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