To add a new column called age to the clients table, use the following SQL statement:
1 2 3 4 5 6 |
ALTER TABLE clients ADD age int; # set default value ALTER TABLE schools ADD distance decimal(10,2) NOT NULL DEFAULT 10000 AFTER zipcode; |
The statement will add the age column to the end of the table.
To insert the new column after a specific column, such as column lastname, use this statement:
1 2 3 |
ALTER TABLE clients ADD age int AFTER lastname; |
To insert the new column to the in front of other columns, use this statement:
1 2 3 |
ALTER TABLE clients ADD age int FIRST; |