Sometimes we need to add a column that we require into the table. We can do this by using ADD keyword with ALTER command.
Syntax:
To add a column into a table, use the following syntax:
ALTER TABLE table_name
ADD COLUMN column_name datatype;
Example: Suppose we have a table user as below:
user
id user_name country
.......................................
1 John Canada
2 Chris America
3 Joy London
4 Jenny Korea
Now we want to add the column named "age" into the "user" table.
We use the following statement:
ALTER TABLE user
ADD COLUMN age int(11);
Result: The "user" table will now look like as below:
id user_name country age
..................................
1 John Canada
2 Chris America
3 Joy London
4 Jenny Korea
0 Comment(s)