Let's say you wanted to track the number of atbats and hits of a player for each year they were in college. To add a column to an existing table, you need to execute the following scripts:
USE foraltering;
ALTER TABLE tableforaltering
ADD COLUMN atbats SMALLINT NULL AFTER yearID;
ALTER TABLE tableforaltering
ADD COLUMN hits SMALLINT NULL AFTER atbats;
If you want to add both columns to the same query, you can execute the following query instead:
USE foraltering;
ALTER TABLE tableforaltering
ADD COLUMN atbats SMALLINT NULL AFTER yearID,
ADD COLUMN hits SMALLINT NULL AFTER atbats;
The following screenshot shows the new columns in the table:
In the next section, you will learn how to drop these columns.