1

Possible Duplicate:
How should I store GUID in MySQL tables?

Hello,

To represent a GUID in MySQL, should I just use varchar? Also, since it is something that will be used to recognize a user, should it be encrypted? Or does that lost the point of having the GUID? :)

Thanks!

Community
  • 1
  • 1
Genadinik
  • 18,153
  • 63
  • 185
  • 284

3 Answers3

0

a GUID is nothing else that a string, so varchar is enough yes. Encryption? No, I don't see the interest, in general we encrypts password in base, not the logins ;)

Arnaud F.
  • 8,252
  • 11
  • 53
  • 102
  • A GUID or UUID is not a string, it's a 128 bit number that can be represented as a hexdecimal string and is usually what people read. Storing it as the actual 16 bytes is far better than varchar or any text type. – Mani Gandham Jun 01 '16 at 01:03
0

Yes, a varchar would be a good choice. Maybe even char, because the length is fixed, tough I don't know if you'd gain anything.

And I can't see why you would want to encrypt it.

Vilx-
  • 104,512
  • 87
  • 279
  • 422
-1

I guess you're coming from a SQL Server background. In MySQL you generally use an INTEGER(10) field with AUTO_INCREMENT as primary key. There's not really any reason to encrypt that value in any way.

halfdan
  • 33,545
  • 8
  • 78
  • 87
  • In SQL server you too generally use an "identity" column which automatically increments. Arguments for choosing a GUID column over an integer are as valid in MySQL world as in SQL Server world. – Vilx- Apr 17 '11 at 21:52
  • Never saw an identity column before actually. Thanks for the info. – halfdan Apr 17 '11 at 21:55
  • I've rarely seen anything else as a primary key. :) I know of only one project that used GUIDs, and they only did it because of the massive synchronization they had to do. – Vilx- Apr 17 '11 at 22:39
  • this is not answer to the question – nawfal Jun 23 '12 at 00:50