填充整个 SQL 表列
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1122790/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Fill entire SQL table column
提问by Dave Markle
I just added a new column in my DB which I need to propagate with a specific text value (Confirmed). Is there a simple way to apply to all my data entries so I don't have to go through all my rows and type the value in?
我刚刚在我的数据库中添加了一个新列,我需要使用特定的文本值(已确认)进行传播。有没有一种简单的方法可以应用于我的所有数据条目,这样我就不必遍历所有行并输入值?
Thanks
谢谢
回答by Dave Markle
you run the statement:
你运行语句:
UPDATE whateveryourtableis SET whateveryourcolumnis = 'whatever';
回答by onedaywhen
Yould could make the desired value the new column's DEFAULT
e.g.
您可以将所需的值设为新列的DEFAULT
例如
ALTER TABLE MyTable ADD
my_new_column VARCHAR(20) DEFAULT 'Confirmed' NOT NULL;
回答by Jamie Ide
Yes there is:
就在这里:
UPDATE [table]
SET [column] = 'Confirmed'