I have the following query for creating a table,
CREATE TABLE IF NOT EXISTS company (
id uuid CONSTRAINT companyid PRIMARY KEY DEFAULT gen_random_uuid(),
name varchar(128) NOT NULL,
db_uri varchar(255) NOT NULL,
c_uri varchar(255) NOT NULL,
date_c timestamp DEFAULT now(),
date_m timestamp DEFAULT now()
) WITH (fillfactor=90);
I am getting the following error when I run it through pgAdminIII.
ERROR: function gen_random_uuid() does not exist
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
********** Error **********
ERROR: function gen_random_uuid() does not exist
SQL state: 42883
Hint: No function matches the given name and argument types. You might need to add explicit type casts.
I have created an extension pgcrypto
as that contains gen_random_uuid() function definition but that also did not help.
I ran the same scripts on a MAC and it all worked fine.
I am using PostgreSQL 9.3.
The issue was with Version of PostgreSQL.
It is in PostgreSQL 9.4 up that, pgcrypto
has the gen_random_uuid()
function.
Got the new version installed and it was all good!