May 2020
Beginner
564 pages
14h 9m
English
To change a column's name, re-add the atbats column first so that you can change it with the following query:
USE foraltering; ALTER TABLE tableforalteringADD COLUMN atbats SMALLINT NULL AFTER yearID;
Let's say you wanted to rename this column to numberofatbats. You can execute the following script to do that:
USE foraltering;ALTER TABLE tableforalteringCHANGE COLUMN atbats numberofatbats SMALLINT;
You can see, in the previous query, that you put in the current name of the column, then the new column name. You also have to put the column data type in, which in this case stays the same, so you just put the current data type into the query. The following screenshot shows the updated column name:
In the next section, you ...
Read now
Unlock full access