如何只删除数据库中的特定列值? [英] How to delete only perticular column values from database ?

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

问题描述

我希望只删除特定列值而不影响数据库中的任何其他列。我怎么能得到这个?

I want delete only perticular column values from without affecting any other column in the database . How can I achive this?

推荐答案

像这样:



Like this:

ALTER TABLE table_name
DROP COLUMN column_name





http://www.w3schools.com/sql/sql_alter.asp [ ^ ]



顺便说一下,是 Google [ ^ ]在你的地方破了?



http://www.w3schools.com/sql/sql_alter.asp[^]

Btw, is Google [^]broken at your place?


Manas BHardwaj解决方案可以工作,但它会删除数据库中的列及其包含的值。因此,如果您的任何其他软件使用该列,它将在尝试访问时失败。



可能您想要摆脱其中的值仅列:这也很简单。

假设列是NVARCHAR:

Manas BHardwaj solution will work, but it deletes the column from the database as well as the values it contains. So if any of your other software uses that column, it will fail when it tries to access it.

It may be that you want to get rid of the values in the column only: that's also pretty simple.
Assuming the column is NVARCHAR:
UPDATE myTable SET MyColumn=''

将删除所有值。

如果列为NULLABLE,则:

Will remove all the values.
If the column is NULLABLE, then:

UPDATE myTable SET MyColumn=NULL

是更好的解决方案。


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

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