如何修改数据库值 [英] How to modify database value

查看:126
本文介绍了如何修改数据库值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在我的网页中进行设计.我的数据库表中的ID允许为空值我已经设置好.我已经将值存储在table.但是我希望ID值不允许为空值.如何在我的表中进行更改

I have designing in my web page .my database table the id is allow null value i have set ok.i had store the value in table.but i want Id values not allow null value .how to change in my table

推荐答案

在企业管理器中,这非常简单,只需删除允许空值"中的复选标记即可.

尝试一个接一个地执行以下语句,
In Enterprise manager, it is very easy, just remove check mark from "Allow Nulls".

Try following statements one by one,
UPDATE [Table] SET [Column]=0 WHERE [Column] IS NULL
ALTER TABLE [Table] ALTER COLUMN [Column] INTEGER NOT NULL


右键单击表格,然后选择修改" ".取消选中相应列上的允许空值"复选框并保存.该表应该为空,或者在继续之前确保该列不包含任何空值.
Right click on the table and select ''Modify''. Un-check the ''Allow Nulls'' checkbox on the appropriate column and save. The table should either be empty or ensure that the column does not contain any null values before you proceed.


假设您正在使用SQL Server,是否已安装SQL Server Management Studio Express?如果没有安装.然后使用它连接到服务器/数据库并修改表-取消选中ID字段的Allow Nulls框并保存.如果您使用的是Linq,则需要将表删除/重新添加到数据上下文中,以使您的代码接受更改.
Assuming you are using SQL Server, do you have SQL Server Management Studio Express installed? If not install it. Then use it to connect to your server / database and modify your table - untick the Allow Nulls box for your ID field and save. If you are using Linq, you then need to remove / re-add the table to your data context so that your code picks up the change.


这篇关于如何修改数据库值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆