How to set default values in a MySQL database
In MySQL database, you can use the DEFAULT keyword to set a default value.
When creating a table, you can use the DEFAULT keyword to set a default value for a column, as shown below:
CREATE TABLE table_name (
column_name data_type DEFAULT default_value
);
You can also modify the default value of an existing table using the ALTER TABLE statement, as shown below:
ALTER TABLE table_name
ALTER COLUMN column_name SET DEFAULT default_value;
It is important to note that if a default value is not specified when creating a table and no value is provided for a column when inserting data, the column will be set to NULL.