URL storage data type

What is the best data type for storing urls?

I need to save file system paths for images in a database.

+4
source share
5 answers

URLs are strings and will have a variable length.

If your database system supports this, use VARCHAR.

+4
source

VARCHAR is quite enough.

CHAR should be used to store the characters of the patch length string. String values ​​will be filled with space / space before saving to disk. If this type is used to store varibale-length strings, it will waste a lot of disk space.

+3
source

VARCHAR2 (4000) is enough for your needs

+2
source

We try to keep them as urlencoded VARCHAR s. (Since our URLs go to the database from the server, we encode them using PHP urlencode and then decode them when we get them using urldecode .) Don’t think that there’s still a lot to do - you probably could just save them as unencoded VARCHAR s.

+2
source

varchar . Choose the appropriate maximum length based on your domain knowledge.

+1
source

All Articles