Saving facebook id as int or varchar?

My question is more advisory than technical.
I’m writing a Facebook app in which I am fetching some information about the user, including facebook_id.
I was wondering if I should keep the user id as INT or VARCHAR in the MySQL database?


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Facebook uses 64-bit integers (bigint) for their user ids. So you use Bigint UNSIGNED in MySQL.

“As a reminder, in the very near future, we will be rolling out 64 bit user IDs. We encourage you to test your applications by going to and create test accounts with 64 bit UIDs.”

Edit: Facebook usernames is not the same thing as the user id. The username is of course varchar but will not be returned as the id.

Method 2

Although unlikely, facebook could change the format of their ID’s, so to make it future proof, I’d use a varchar.

Method 3

similar question to: Facebook user_id : big_int, int or string?

“I would not use a string. That makes comparisons painful and your indexes clunkier than they need to be.”

Method 4

To quote facebook’s upgrade notes regarding graph API v2.0 (effective May 2015):

All IDs are strings. In v1.0, IDs were often large numbers.

Which (to me) implies that userids are not guaranteed to be numbers. In fact, facebook recommend that you use strings:

Description: id The id of this person’s user account.

This ID is unique to each app and cannot be used across different apps(…)

type: string

Although I must admit I’ve never seen an alphanumeric id.

Method 5

Use BIGINT(64) to store Facebook User IDs.
Here you go:

Method 6

For new data types, as they are grahp obj ID, I believe it is safe to save them as BINT.
However, for old “id”, e.g. pic, save them as string (you can easily see that they are in the format xxxxxx_xxxxxxxx)

Method 7

I’d use INT, because it’s not so big. Searching in INT is faster and betterfor ordering

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x