I'm not sure that I understand exactly, maybe something like this:
SELECT ROUND(RAND() * 123456789) as id
The more you make the number, the larger your identifier.
There is no guarantee of uniqueness, of course, this is a quick hack in the end, and you should implement code verification to deal with the randomness in which the duplicate is inserted, but maybe this will serve your purpose?
Of course, there are many other approaches for this.
You can easily use most scripting languages ββto generate this for you, e.g. php:
//Generates a 32 character identifier that is extremely difficult to predict. $id = md5(uniqid(rand(), true)); //Generates a 32 character identifier that is extremely difficult to predict. $id = md5(uniqid(rand(), true));
Then use $id in your request or whatever you need for your unique identifier. In my opinion, the advantage of this in the scripting language when interacting with the database is that it is easier to check for the purposes of use / use and act accordingly. For example, in your example, no matter what method you use, if you want to be 100% sure of the integrity of the data, you need to make sure that there are no duplicates of this identifier elsewhere. This is easier to do in a script than in SQL .
Hope this helps my friend, good luck!
source share