Schema Modification in SQL | ALTER, DROP & RENAME
When working with databases, creating tables is only the first step. As applications grow, database requirements change — new columns are…
Schema Modification in SQL | ALTER, DROP & RENAME
When working with databases, creating tables is only the first step. As applications grow, database requirements change new columns are needed, old ones removed, or data types modified.
This is where Schema Modification in SQL becomes important.
In this article, you will learn:
- What schema modification means
- SQL commands used to modify table structure
- Real-world examples
- Common mistakes to avoid
What is Schema Modification in SQL?
Schema modification refers to changing the structure of an existing database object such as:
- Tables
- Columns
- Constraints
These changes do not affect the database itself, but they update how data is stored or organized.
SQL provides special commands called DDL (Data Definition Language) commands for this purpose.
ALTER TABLE — Modifying Table Structure
The ALTER TABLE command is the most commonly used schema modification command.
1. Add a New Column
ALTER TABLE employees
ADD email VARCHAR(100);
Adds a new column named email to the employees table.
2. Modify an Existing Column
ALTER TABLE employees
MODIFY salary DECIMAL(10,2);
Changes the data type or size of an existing column.
3. Rename a Column
ALTER TABLE employees
RENAME COLUMN name TO full_name;
Renames a column without affecting data.
4. Drop a Column
ALTER TABLE employees
DROP COLUMN age;
This permanently removes the column and its data.
DROP TABLE — Deleting a Table Completely
DROP TABLE employees;
Deletes the table and all its data permanently.
Use with caution — this action cannot be undone.
RENAME TABLE — Changing Table Name
RENAME TABLE employees TO staff;
Useful when refactoring database design.
TRUNCATE TABLE — Remove All Records
TRUNCATE TABLE employees;
✔ Deletes all rows
✔ Keeps table structure
✔ Faster than DELETE
Real-World Example
Imagine you launched an application with this table:
CREATE TABLE users (
id INT,
name VARCHAR(50)
);
Later, you need:
- Email column
- Longer name length
ALTER TABLE users
ADD email VARCHAR(100);
ALTER TABLE users
MODIFY name VARCHAR(100);
This is schema modification in action.
Common Mistakes to Avoid
Dropping columns without backup Modifying column types that already contain data Running schema changes directly on production databases
Always test changes in a development environment first.
Key Points to Remember
- Schema modification changes structure, not data values
ALTER TABLEis the most important command- Always take a backup before making changes
- Use schema changes carefully in live systems
Learn SQL the Smart Way
If you want to master SQL step by step with:
- MCQs: https://www.quipoin.com/practice-mcqs
- Exercises: https://www.quipoin.com/exercise
- Interview questions: https://www.quipoin.com/interview
- Real-world examples
👉 Visit **www.quipoin.com**
At Quipoin, we simplify SQL, Java, Spring, and Web Development for beginners and professionals alike.
Practice more. Learn better. Grow faster with Quipoin.
메타데이터
- post_id
- 38a2feaaba75
- slug
- schema-modification-in-sql-alter-drop-rename-38a2feaaba75
- url
- https://medium.com/@quipoin04/schema-modification-in-sql-alter-drop-rename-38a2feaaba75
- canonical_url
- https://medium.com/@quipoin04/schema-modification-in-sql-alter-drop-rename-38a2feaaba75
- author_url
- https://medium.com/@quipoin04
- status
- ok
- fetched_at
- 2026-07-13 13:01:55