Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the proper column type to save urls in MySQL?

Tags:

mysql

I've been using varchar(300),but I've also noticed longer urls.

like image 708
user198729 Avatar asked Sep 20 '25 02:09

user198729


1 Answers

Use TEXT, it's enough for every URL.

Note that with long URLs, you won't be able to create an index that covers the whole URL. If you need a UNIQUE index, you should calculate the URL hash, store the hash separately and index the hash instead.

like image 147
Quassnoi Avatar answered Sep 22 '25 01:09

Quassnoi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!