在SQL中,如何在现有表中添加新列后添加值?
  我创建了一个表并插入了3行。  然后我使用alter添加了一个新列。  如何在不使用任何空值的情况下向列添加值? 
两种解决方案
这个:
ALTER TABLE YourTable
ADD YourNewColumn INT NOT NULL
DEFAULT 10 
WITH VALUES;
null值的列。  然后更新所有行以输入所需的值。 像这样:
ALTER TABLE YourTable
ADD YourNewColumn INT NULL;
UPDATE YourTable SET YourNewColumn = 10; -- Or some more complex expression
  然后,如果需要,请更改列以使其not null : 
ALTER TABLE YourTable ALTER COLUMN YourNewColumn NOT NULL;
你为什么不使用UPDATE语句:
UPDATE tablename SET column=value <WHERE ...>
哪里是可选的。 例如在T-SQL for table中:
我可以通过以下语句更新列NewTestColumn:
UPDATE [dbo].[Table] SET [NewTestColumn] = 'Some value'
   update table_name
   set new_column=value
上一篇: In SQL, How to add values after add a new column in the existing table?
下一篇: Add a Column that Represents a Concatenation of Two Other Varchar Columns
