(a) Assuming that the table WSTOCK is already created, write an SQL command to add an attribute EDate (of DATE type) to the table.
OR
(b) Assuming that the table WSTOCK is already created, write an SQL command to remove the column BQty from the table.
(a) Assuming that the table WSTOCK is already created, write an SQL command to add an attribute EDate (of DATE type) to the table.
OR
(b) Assuming that the table WSTOCK is already created, write an SQL command to remove the column BQty from the table.
(a) Add column E_Date of DATE type:
``sql
ALTER TABLE WSTOCK ADD EDate DATE;
`
(b) Remove column B_Qty:
`sql
ALTER TABLE WSTOCK DROP COLUMN BQty;
`
(Equivalently written as ALTER TABLE WSTOCK DROP BQty;` in some SQL dialects — both are accepted.)
Marking Scheme
- 11 mark: correct `ALTER TABLE W_STOCK ADD E_Date DATE;` for part (a), OR correct `ALTER TABLE W_STOCK DROP COLUMN B_Qty;` for part (b).
Hint
Use ALTER TABLE ... ADD column datatype; to add a column, and ALTER TABLE ... DROP COLUMN column; to remove one.
Quick Oral Answer
ALTER TABLE ADD lets me add a new column like E_Date to an existing table without losing existing data, while ALTER TABLE DROP COLUMN permanently removes a column such as B_Qty along with all its stored values.
Analysis & Explanation
Both parts test the ALTER TABLE statement, which is used to modify the structure of an existing table without deleting its data.
Concept
ALTER TABLE ... ADD columnname datatype; inserts a brand-new column into every existing row (initialised to NULL). ALTER TABLE ... DROP COLUMN columnname; permanently removes a column and all its stored data from every row.
Exam trap
A very common mistake is confusing ALTER TABLE (used to change table structure) with UPDATE (used to change row data). Another frequent slip is misspelling the keyword as MODIFY when adding a new column — MODIFY is used only to change an existing column's data type, not to add a new one.
Real-world relevance
These commands reflect how real production databases evolve over time — e.g. adding an expiry date field to a stock table as new business requirements emerge, or removing a field once it becomes obsolete.
Common Mistakes
- 1Using MODIFY instead of ADD when introducing a brand-new column — MODIFY only changes the definition of an already-existing column.
- 2Forgetting the keyword COLUMN in the DROP command (though many SQL dialects accept DROP B_Qty without it, CBSE answers typically expect DROP COLUMN).
- 3Writing UPDATE W_STOCK instead of ALTER TABLE W_STOCK, confusing structural changes with data changes.
Interesting Facts
ALTER TABLE belongs to SQL's Data Definition Language (DDL), while commands like UPDATE and DELETE that change row data belong to the Data Manipulation Language (DML) — a distinction frequently tested in CBSE.
Dropping a column with ALTER TABLE ... DROP COLUMN is irreversible and destroys all data stored in that column across every row — most real database systems recommend taking a backup before running such a command.
Spotted a mistake or something unclear?
Tell us — we fix reported answers fast.
Frequently Asked Questions
What is the difference between ALTER TABLE ADD and MODIFY?
ADD is used to introduce a brand-new column into an existing table, while MODIFY is used to change the data type or size of a column that already exists in the table.
Does dropping a column delete the data in it permanently?
Yes, ALTER TABLE ... DROP COLUMN permanently deletes that column and all the data stored in it for every row of the table; this action cannot be undone.