Hello list,
I want to generate random numbers in Pl/pgSQL. How can I do this?
To be more specific, I have to generate random numbers among 0 and 5.
Thanks in advance.
Regards, Karel Riverón
Student Scientific Council
Informatics Science University
http://www.uci.cu
On Sat, May 25, 2013 at 8:45 AM, Karel Riveron Escobar
kesco...@estudiantes.uci.cu wrote:
I want to generate random numbers in Pl/pgSQL. How can I do this?
To be more specific, I have to generate random numbers among 0 and 5.
One way:
select n from unnest(ARRAY[0,1,2,3,4,5]) n order by
2013/5/26 bricklen brick...@gmail.com:
On Sat, May 25, 2013 at 8:45 AM, Karel Riveron Escobar
kesco...@estudiantes.uci.cu wrote:
I want to generate random numbers in Pl/pgSQL. How can I do this?
To be more specific, I have to generate random numbers among 0 and 5.
One way:
select n from
Thanks bricklen.
I found another way in PostgreSQL 9.1.0 Documentation.
SELECT * INTO random_number FROM random(); -- random function gives me a random
value among 0.0 -- and 1.0
SELECT * INTO rounded_number FROM round(random_number * 5); -- this line is
completly obviously.
Saludos, Karel
On 25 May 2013 17:56, Ian Lawrence Barwick barw...@gmail.com wrote:
2013/5/26 bricklen brick...@gmail.com:
On Sat, May 25, 2013 at 8:45 AM, Karel Riveron Escobar
kesco...@estudiantes.uci.cu wrote:
I want to generate random numbers in Pl/pgSQL. How can I do this?
To be more specific,
How would be if I would want to generate values among 3 and 5?
Regards, Karel Riverón
Student Scientific Council
Informatics Science University
- Original Message -
| From: Szymon Guz mabew...@gmail.com
| To: Ian Lawrence Barwick barw...@gmail.com
| Cc: bricklen brick...@gmail.com, Karel
On 25 May 2013 18:14, Karel Riveron Escobar kesco...@estudiantes.uci.cuwrote:
How would be if I would want to generate values among 3 and 5?
Hi Karel,
try something like:
SELECT floor(3 + random()*(5-3+1))::INT
Or generally:
CREATE OR REPLACE FUNCTION
random_range(INTEGER, INTEGER) RETURNS
I just created a new partition in a log table, and then built a check
constraint on the recorded timestamp column.
I have an index on this column, but the adding of the check constraint took
a very, very long time.
It seems that PostgreSQL 9.1 does not check the index when building a check
On 25/05/2013 20:37, Moshe Jacobson wrote:
I just created a new partition in a log table, and then built a check
constraint on the recorded timestamp column.
I have an index on this column, but the adding of the check constraint
took a very, very long time.
It seems that PostgreSQL 9.1