How to add a new column and assign a value in SQL?
To add a new field and assign a value in an SQL database, you can use the ALTER TABLE statement. Here is an example:
Suppose we have a table called “employees” and we want to add a field named “salary” to this table with a default value of 1000 for all employees. This can be achieved using the following SQL statement:
ALTER TABLE employees
ADD COLUMN salary INT DEFAULT 1000;
This adds a new field named “salary” to the “employees” table and sets the default value for all employees’ salaries to 1000.