Reputation:
Suppose that I have such table :
and I would like to delete all the rows of columns score
year
and month
, without modifying id
and name
.
Can anyone help me?
Upvotes: 0
Views: 45
Reputation: 8101
You're looking for an UPDATE
, not a DELETE
. DELETE
only operates on full rows.
So:
UPDATE table
SET
score = NULL,
year = NULL,
month = NULL;
You usually want a WHERE
clause on an UPDATE
, but if you want to wipe out all the current data in those columns, you don't need one here.
Since it's numeric data, you could set them all to 0
instead of NULL
, depending on your preferences and needs, and also the nullability setting for each column. Anything defined with NOT NULL
at table creation will have to be updated to an acceptable value, like a 0
for an integer.
Upvotes: 4