[SOLVED] Dynamically reduce DBASE table name to be within the 64 character limit

I am trying to create table names based on the full path directory name. Unfortunately MySql has a maximum table name length limit of 64.

I have tried the following example:


$fullPath ==> /var/www/fred.com/public_html/this-is-far-too-long-and-does-not-allow-the-dbase-table-name-to-be-dynamically-produced/

118  ==> strlen($fullPath)

92   ==> gzdeflate($fullPath, 9) // 9 is mazimum compression :(
98   ==> gzcompress($fullPath, 9)
110  ==> gzencode($fullPath, 9)
// ADDED
13  ==> crypt($fullPath, "SALT") ==> SAgeUyK6492uo
32  ==> md5($fullPath) ==> de4deea89afea038f8a5619c4c3659dc

Before I create a cross-reference lookup table I am curious to know if there is an easier solution.

Edit:
Added crypt(…) and md5(…) which should solve the problem.

How about md5?

1 Like

I don’t know if you could use it or not but “alias” for column names has a 256 limit (except in VIEWs).

https://dev.mysql.com/doc/refman/5.7/en/identifiers.html

1 Like

Many thanks,

I think with a bit of juggling crypt(…) or md5(…) may solve the problem:

From @Mittineague’s link:

https://dev.mysql.com/doc/refman/5.7/en/identifiers.html

Be careful when using MD5() to produce table names because it can produce names in illegal or ambiguous formats such as those just described.

2 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.