Hal Clive
Hal Clive

Reputation: 137

Converting table index from Int to Bigint MySQL

I've been running a small web-based experiemnt using Facebook UIDs to verify unique users.

Recently I've discovered that UIDs can be bigger than I realised among some users, so my int-based system is now inadequate and I need to convert to bigint.

I can't risk losing the results I already have, but need to convert the table so that the index containing the uid is now bigint. Are there any particular issues changing the type of an index column, and would it be as simple as:

ALTER TABLE breadusers MODIFY userid bigint;

?

Upvotes: 6

Views: 11304

Answers (2)

Faizan Noor
Faizan Noor

Reputation: 736

For the Facebook UID part, I would suggest you to go for BIGINT(64). Here is the answer from Facebook Blog: https://developers.facebook.com/blog/post/45/

Upvotes: 0

John Parker
John Parker

Reputation: 54425

In theory this should be absolutely fine, although it the data really matters, I presume you have a recent backup anyway in case something goes awry.

That said, I'd probably be tempted to store the Facebook UID as a string (i.e.: in a VARCHAR field) and simply have a generic auto-incremented ID field. Then again, that's an answer to a different question. :-)

Upvotes: 3

Related Questions