Closed. This question needs details or clarity . It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post .
Closed 2 days ago.
Improve this question
Is it possible to delete all data from a specific column without affecting data in other columns within the same row, without using an update query? I don't want to drop the column.
2条答案
按热度按时间1tuwyuhd1#
fumotvh32#
If you want to "delete" the values in a column in all rows then you need to
UPDATE
the table;DELETE
deletes rows not values in a specific column. So, in pseudo-SQL this would be:What your new value is is up to you; it might be
NULL
, a zero length string (''
),0
, etc.Such an operation will be an offline operation though, so for a large table this could result in a lengthy lock. If so, and you're on Enterprise/Developer, you might want to consider
DROP
ing and reADD
ing the column, provided that nothing else is dependent on said column. This is because adding a column (with a default value) is an online process in Enterprise, as it's a metadata change:If you want
NULL
/NOT NULL
aDEFAULT
CONSTRAINT
,WITH VALUES
, etc, is dependant on your needs.For transparency, I VTC'd after posting this answer, as from the comments on the question, it appears that the question asked and the question the OP wants to ask are not the same. This answer addresses the question asked; it is unclear what the OP is really asking.