Here we will learn Random() function in SQLite and how to use SQLite Random() function to get the random number with examples.
In SQLite Random() function is used to return the random 64-bit signed integer value between “-9,223,372,036,854,775,808” to “+9,223,372,036,854,775,807”.
The maximum integer returned by random() function is +9,223,372,036,854,775,807 and the minimum integer value returned by random() is -9,223,372,036,854,775,808. This means that it may return positive or negative integers as a random number.
Every time when we execute SQLite Random() function we will get different result between “-9,223,372,036,854,775,808” to “+9,223,372,036,854,775,807”
Following is the syntax of SQLite Random() function to get the random number value.
Now we will see how to use SQLite Random() function to get the random value with examples.
Following are the simple examples of SQLite Random() function to get the random value.
sqlite> SELECT random();
random()
--------------------
-7824025347360374273
sqlite> SELECT random();
random()
-------------------
6590755322680007246
sqlite> SELECT random();
random()
--------------------
-3710903417443170290
sqlite> SELECT random();
random()
--------------------
-8943791220128736495
This is how we can use SQLite Random() function to get the random value based on our requirements.