Solved

How to generate random int64 Postgresql?

Posted on 2012-03-28
1
735 Views
Last Modified: 2012-04-11
Hi Experts,

I want to create function to generate random int64 using Postgresql.

Any suggestion code? Thanks before.
0
Comment
Question by:jimmycdinata
1 Comment
 
LVL 22

Accepted Solution

by:
earth man2 earned 500 total points
ID: 37790211
try built in random() function gives random number between 0.0 and 1.0


select cast(9223372036854775807 *  (2.0 *(random()- 0.5))as bigint)+ case (random()> 0.5) when true then -1 else 0 end;

if you are on linux or unix the reading direct from /dev/random may be the right option using a c function.

it depends on how random your random number must be.  Often modern motherboards have white noise random number hardware it depends....
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Best database to use for Maps is PostgreSQL. This is an open source database. Comes as a package with most Linux OS. For more info visit the following site: http://www.postgresql.org/ (http://www.postgresql.org/) This requires some add-o…
Many developers have database experience, but are new to PostgreSQL. It has some truly inspiring capabilities. I have several years' experience with Microsoft's SQL Server. When I began working with MySQL, I wanted a quick-reference to MySQL (htt…
Steps to create a PostgreSQL RDS instance in the Amazon cloud. We will cover some of the default settings and show how to connect to the instance once it is up and running.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now