How to save link in mysql?

I need to save some link in mysql, but some link is smaller and others can be very large.

In which field should I use in mysql (varchar, TEXT, ecc)?

+3
source share
3 answers

Varchar is a good choice. TEXT is for big data and stored outside the table. For more information read VARCHAR vs TEXT in MySQL

+4
source

Most parameter url will be insufficient on varchar (255). Using text that can accept 65535 bytes will be enough.

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

Edit: But if you use mysql more than 5.0.3, then varchar (255) is higher than 65535, so it is better to use it as varchar (20000) for URLs.

VARCHAR . 0 255 MySQL 5.0.3, 0 65 535 5.0.3 . VARCHAR MySQL 5.0.3 (65 535 , ) set used

+4
varchar(255)

should work fine.

+2
source

All Articles