我们可以在已经在sql中有记录的表中添加带有NOT NULL的新列 [英] can we add new column with NOT NULL in table which already have records in sql
本文介绍了我们可以在已经在sql中有记录的表中添加带有NOT NULL的新列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好b $ b
我有一个问题。如果我收到回复会很棒
我们可以在表格中添加带有NOT NULL的新列,这些列已经在sql中有记录吗?
如果是,那么最有效的方法是什么?
问候
Anups
Hi
I have a question in mind. Would be great if i got a reply
can we add new column with NOT NULL in table which already have records in sql ?
If Yes ,then what would be the most effient way to do this ?
Regards
Anups
推荐答案
是的,当然。
你需要指定默认值 - 这不是空的。
Yes, of course.
You need to specify default value - that is not null.
alter table mytable add newcolumn int not null default 0
请尝试以下qry,
更改表TableName添加字段名称CONSTRAINT [Constraint_Name] DEFAULT((0))
问候
M.Mani
Kindly try the below qry,
Alter Table TableName Add fieldname CONSTRAINT [Constraint_Name] DEFAULT ((0))
Regards
M.Mani
非常感谢您的回复
问候
Anups
Thanks a lot for reply
Regards
Anups
这篇关于我们可以在已经在sql中有记录的表中添加带有NOT NULL的新列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文