How to add a column in SQL and assign a value to it?
To add a new column to a table and assign values to that column, you can use the ALTER TABLE statement. Here is an example of the syntax:
ALTER TABLE table_name
ADD column_name data_type DEFAULT default_value;
For instance, if you want to add a column named age to a table called students and set all values to 18, you can execute the following SQL statement:
ALTER TABLE students
ADD age INT DEFAULT 18;
This will add an integer column named age to the students table, and set the age column values of all rows to 18.