May 2020
Beginner
564 pages
14h 9m
English
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 tableforalteringADD COLUMN atbats SMALLINT NULL AFTER yearID;ALTER TABLE tableforalteringADD 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 tableforalteringADD 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.
Read now
Unlock full access