sql whinge

In SQL, when you add a column to a table, you just say ‘add’, e.g.

ALTER TABLE my_table
ADD my_new_column VARCHAR(12);

But if you want to remove a column you have to say ‘drop column’, like this:

ALTER TABLE my_table
DROP COLUMN my_old_column;

This is one of those little inconsistencies that drives me mad – I always forget the ‘column’ part when I am removing one.

(Of course in Rails, one can write migrations in Ruby, and not worry about all this SQL syntax. But I’m not working in Rails in the day job.)

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*