Instruction
Splendid work! Let's do a quick summary. In this part you've learned:
- How to remove the table:
DROP TABLE airplane_ticket;
- How to add a column to a table:
ALTER TABLE flight ADD COLUMN duration_minutes integer;
- How to remove a column from a table:
ALTER TABLE flight DROP COLUMN operated_by;
- There is no standard syntax to rename a table or a column. In Oracle, PostgreSQL, and MySQL, you can use the
ALTER TABLEsyntaxALTER TABLE air_travel RENAME TO flight; ALTER TABLE flight RENAME COLUMN code TO booking_ref;
Meanwhile, SQL Server uses a completely different syntax:exec sp_rename 'plane_schema.air_travel', 'flight' exec sp_rename 'plane_schema.flight.code', 'booking_reg', 'COLUMN';
Now, it's time for a pop quiz.
Exercise
Your task is to modify the structure of kitchen_setting table. It has the following columns: id (integer, primary key), customer_id (integer), area (integer) and address (varchar).
- Rename the
areacolumn toarea_m2. - Delete the
customer_idcolumn. - Add the
designer_idcolumn of type integer.
Stuck? Here's a hint!
Type:
ALTER TABLE kitchen_setting RENAME COLUMN area TO area_m2; ALTER TABLE kitchen_setting DROP COLUMN customer_id; ALTER TABLE kitchen_setting ADD COLUMN designer_id INT;



