TIMEX
TIMEX

Reputation: 271764

How do I change the column of a MySQL to have another default value?

RIght now the server default is 1. How can I change it to 0?

THis is currently the column:

+----------------+--------------+------+-----+---------+----------------+
| Field          | Type         | Null | Key | Default | Extra          |
+----------------+--------------+------+-----+---------+----------------+
 friend_posting | tinyint(1)   | NO   |     | 1       |                |

It has no foreign keys or anything.

Upvotes: 1

Views: 46

Answers (1)

Andrew Leach
Andrew Leach

Reputation: 12973

http://dev.mysql.com/doc/refman/5.1/en/alter-table.html

ALTER TABLE table_name
  ALTER COLUMN friend_posting
  SET DEFAULT 0

This won't change existing rows of course; they will need to be explicitly updated. It only sets the default for new rows.

Upvotes: 1

Related Questions