How do you add a new column to a MySQL table and set a default value?

You can use the ALTER TABLE statement to add a new column to a MySQL table and set a default value.

For example, if you want to add a new field called “age” to a table named “users” and set the default value to 30, you can execute the following SQL statement:

Add a new column called “age” to the users table with a default value of 30.

This will add an INT type field named “age” to the “users” table and set its default value to 30.

bannerAds