How to add a field in SQL and set a default value for i…
In SQL, you can use the ALTER TABLE statement to add a column and set a default value.
Here is an example:
ALTER TABLE 表名
ADD 列名 数据类型 DEFAULT 默认值;
Please replace the “table name” in the above code with the name of the table to which you want to add a field, replace “column name” with the name of the field you want to add, replace “data type” with the data type you want to use, and replace “default value” with the value you want to set as the default.
For example, if you want to add a field named “age” with a default value of 30 to a table named “customers”, the code would be as follows:
ALTER TABLE customers
ADD age INT DEFAULT 30;
This will add an INT type field named “age” to the “customers” table, with a default value of 30.