SQLite Random() Function

Here we will learn Random() function in SQLite and how to use SQLite Random() function to get the random number with examples.

SQLite Random() Function

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

Syntax of SQLite Random() Function

Following is the syntax of SQLite Random() function to get the random number value.

 

random()

 

Now we will see how to use SQLite Random() function to get the random value with examples.

SQLite Random() Function Examples

Following are the simple examples of SQLite Random() function to get the random value.

 

sqliteSELECT random();

 

random()

--------------------

-7824025347360374273

 

sqliteSELECT random();

 

random()

-------------------

6590755322680007246

 

sqliteSELECT random();

 

random()

--------------------

-3710903417443170290

 

sqliteSELECT random();

 

random()

--------------------

-8943791220128736495

This is how we can use SQLite Random() function to get the random value based on our requirements.