This is an article to remind me how to modify a column in a database table the old fashioned way (as in stop making me use GUI interfaces so poorly programmed when even I've made better DBMS tools).
All SQL
-- Add a column to an existing table (giving it datatype char(2) and allowing NULL)
ALTER TABLE myTable ADD myColumn CHAR(2) NULL
-- Delete a column
ALTER TABLE myTable DROP COLUMN myColumn
-- Reorder a column
ALTER TABLE myTable MODIFY COLUMN misplacedColumn AFTER otherColumn;
MySQL and Oracle PL/SQL
ALTER TABLE myTable
MODIFY myColumn myDataType
Microsoft Transact SQL (T-SQL)
ALTER TABLE myTable
ALTER COLUMN myColumn myDataType
Discussion
Comments
Questions, corrections and useful additions are reviewed before appearing here.
No comments yet. Start the discussion.