Reputation: 80
I need to create an alias to the RANDOM() function that is provided by PostgreSQL. I would like to name the new function RAND(). The function takes no parameters and should do the same thing whether invoked using RANDOM() or RAND().
Software that I'm using supports different database backends. The RAND() function exists in MySQL, but in PostgreSQL the same function is called RANDOM(). Without needing to modify the software's code, I'd like to call RAND() from PSQL.
Upvotes: 1
Views: 602
Reputation: 121784
Create a wrapper function:
create function rand()
returns float language sql as $$
select random()
$$;
Upvotes: 4