MySQL Add Column: Guide with Examples
To add a column in MySQL, you can use the ALTER TABLE statement.
Here is the grammar:
Add a column with specified data type and constraints to the table.
For instance, to add a field named “age” in a table called “users”, you can use the following statement:
Add a column called age of type integer to the existing table users.
You can use the COMMENT keyword to add comments to a field.
Here is the grammar.
Change the column type and comment of a field in a table.
For example, to add a comment “user age” to the field named “age”, you can use the following statement:
Change the data type of the ‘age’ column in the ‘users’ table to integer and include a comment stating that it represents the user’s age.