Summary - ALTER and DROP
- SQL course
- Intermediate
- Lesson 111/115
- 5 min
Safely update a table with ALTER TABLE.
Summary - ALTER and DROP
ALTER TABLE adds/drops/modifies columns. DROP TABLE removes a table entirely.
ALTER TABLE products
ADD COLUMN stock INT;Summary ALTER query.
Practice Summary - ALTER and DROP
Summary: add a stock INT column to products.
Starter code
-- summary alter
ALTER TABLE productsSample solution
ALTER TABLE products
ADD COLUMN stock INT;Expected output
Tablo güncellendi
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 Which command removes a table entirely?
- ALTER TABLE
- DROP TABLE Correct answer
- DELETE FROM
- TRUNCATE
Explanation: DROP TABLE removes a table entirely.
2 Summary - ALTER and DROP: match the terms
| Term | Meaning |
|---|---|
ADD COLUMN |
add column |
DROP COLUMN |
drop column |
ALTER COLUMN |
change type |
DROP TABLE |
drop table |