3

I'm trying to store signatures in a database. I'm using a the signature pad plugin (signaturePad) which converts from canvas to JSON and now want to store the signature in MySQL.

I'm using a VARCHAR field, but I'm not sure which length I should allow. I tried several times and usually end up with a string between 2000 and 3000 characters.

Question:
What should I use for field length in MYSQL? I don't know how the CANVAS=>JSON conversion is done, so maybe someone can give me a pointer on what to expect?

Thanks!

frequent
  • 27,643
  • 59
  • 181
  • 333

3 Answers3

4

I would not use VARCHAR, I would use TEXT. You may sacrifice performance in doing this, but you won't have to worry about size constraints.

Edit:

Also, the maximum of VARCHAR is VARCHAR(65535). Just making a note there..

burmat
  • 2,548
  • 1
  • 23
  • 28
2

Don't use VARCHAR. Use TEXT.

Outlined in the docs for the signaturePad plugin

Dancrumb
  • 26,597
  • 10
  • 74
  • 130
2

probably better off using one of the TEXT datatypes.

TINYTEXT    256 bytes    
TEXT    65,535 bytes    ~64kb
MEDIUMTEXT   16,777,215 bytes   ~16MB
LONGTEXT    4,294,967,295 bytes ~4GB

It also depends on your version of MySQL.

see: Is a VARCHAR(20000) valid in MySQL?

Community
  • 1
  • 1
djjolicoeur
  • 484
  • 3
  • 7